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