Posts

Showing posts with the label foreach

json_decode foreach into table

Image
Clash Royale CLAN TAG #URR8PPP json_decode foreach into table Having Issues with nested arrays I Want to get the array title into the first cell of the table, having an issue articulated the nested foreach. $content = file_get_contents("https://whattomine.com/asic.json"); $data = json_decode($content); echo "coins"; foreach() { echo "<tr>"; echo "<th>".$coins->coinname."</th>"; echo "<th>".$coins->PoW."</th>"; echo "<th>".$coins->PoS."</th>"; echo "<th>".$coins->height."</th>"; echo "<th>".$coins->diff."</th>"; echo "<th>".$coins->supply."</th>"; echo "</tr>"; } By clicking "Post Your Answer", you acknowledge that you have read our updated terms o...

foreach loop with $value didnot work together with sqlselect where $value

Image
Clash Royale CLAN TAG #URR8PPP foreach loop with $value didnot work together with sqlselect where $value I made foreach loop for index array to print a table. $value is also used for echo some values from next associative array(s)... I would use $value for MySQL select table where var $value is used for WHERE parameter. But nothing happend. Maybe could someone find the bug. Im helpless now, Im working on it last 14 hours and my brain is usless now. Can somebody help please? Its all in this part of code: foreach ($seraz_soupis_pot as $key => $value) { $sqlshowpotraviny = "SELECT nazev, jednotka, jednotkajeg FROM ft_potraviny WHERE nazev = $value"; $resultshowpotraviny = mysqli_query($link, $sqlshowpotraviny); $rowshowpotraviny = mysqli_fetch_assoc($resultshowpotraviny); if ($rowshowpotraviny['jednotka'] == "g") { $nasobek = ""; $jednotka = ""; ...

Powershell comparing two List with foreach

Image
Clash Royale CLAN TAG #URR8PPP Powershell comparing two List with foreach I'm trying to compare two lists that I obtained with the Get-ChildItem cmdlet. Get-ChildItem I read about the Compare-Object cmdlet, but in this context I would prefer doing with a foreach because is useful to have access to the $file variable. Compare-Object $file $StartingFolderPath = "C:---StartingFolder" $EndingFolderPath = "C:---EndingFolder" $AllStartingFiles = Get-ChildItem $StartingFolderPath $AllEndingFiles = Get-ChildItem $EndingFolderPath Write-Host "First folder content:"$AllStartingFiles Write-Host "Second folder content:" $AllEndingFiles foreach($file in $AllEndingFiles){ write-Host "Element :" $file.Name $result = $AllStartingFiles.Contains($file.Name) write-host $result if($AllStartingFiles.Contains($file.Name)){ Write-Host "You are here" Write-Host $file.Name } } But it seems that I cannot pass the...