So I have the following, working code:
$arrayitertest=Array("Fruit"=>Array("Pear","Peach","Apple","Banana"),"Cars"=>Array("My budget","other cars."));
foreach ($arrayitertest as $key=>$value)
foreach($arrayitertest[$key] as $result) echo $key.":". $result."|";
But when I change foreach ($arrayitertest as $key => $value) to foreach ($arrayitertest as $key) it throws a fatal error (despite the fact I never use the $key variable.)
The Error is:Invalid argument supplied for foreach() in
Could someone be so kind as to tell me why that happens ?
Edit: Wow, thanks for all the answers.... I will give the accept to the most specific one as of this moment though.
//echo $value."|".$key1."\n";to/*echo $value."|".$key1."\n";*/to correctly comment out the code within the foreach.