title: PHP multidimensional array print to browser showing nested arrays
body: <p>I am trying to solve the following problem:</p>
  
  <p>Note I am new to programming and PHP and working through <code>SAMS PHP, MySQL and Apache (Julie C. Meloni).</code></p>
  
  <p>There is an exercise where a multidimensional array has to be created. The outer array is an associative array listing the genres of movies. The genre arrays list movies of that genre. You are then asked to print out a list of genres with the list of films associated with that genre.</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;?php 
  $genres = array(
      'Science Fiction' =&gt; array('Star Trek', 'Star Wars', 'Alien'),
      'Drama' =&gt; array('Les Amant de Pont Neuf', 'War &amp; Peace', 'Bridehead Revisited'),
      'Crime' =&gt; array('Heat', 'Pulp Fiction', 'Messerine')
  );
  $gKeys = array_keys($genres);
  foreach ($gKeys as $genre) {
     print $genre."&lt;br/&gt;";
  
  }
  ?&gt;
  </code></pre>
  
  <p>This works and prints out:</p>
  
  <blockquote>
    <p>Science Fiction</p>
    
    <p>Drama</p>
    
    <p>Crime</p>
  </blockquote>
  
  <p>Here's where I am running into a wall. When I try adding another foreach loop after </p>
  
  <pre><code>print $genre;
  </code></pre>
  
  <p>no results appear in the browser (except results of first loop). I have tried everything. For example:</p>
  
  <ul>
  <li>starting by using the array_value() function applied to $genre and then try a foreach on the array returned.</li>
  <li>In the textbook there is also a while (list($x) = ($y)) mechanism mentioned.</li>
  <li>I thoroughly re-read the array chapter and have looked elsewhere to no avail.</li>
  </ul>
  
  <p>perhaps I have structured the multidimensional array incorrectly? Do the second dimensional arrays need to be associative arrays also for consistency?</p>