title: PHP Bidimensional array and foreach loops
body: <p>I follow struggling with bidimensional arrays and foreach loops. The following code shows a magazines array, each of them points to an unidimensional Articles array. Right now is storing three Articles for each magazine (just the Article's Title). I would like to know how to associate a Bidimensional array so that can I store the Author and PagesNumber besides the Title, for each article belonging a magazine. Could you point me in the right direction? Thanks in advance.</p>
  
  <pre><code>&lt;?php
  
  // Create a magazines array
  $magazines = array();
  
  // Put 5 magazines on it
  for($x=0;$x&lt;5;$x++)
      $magazines[] = "Magazine " . $x ;
  
  // Associate articles array to each magazine
  foreach($magazines as $magazine){
      $articles[$magazine] = array();
      for($x=0;$x&lt;3;$x++)
          $articles[$magazine][] = $magazine . " - Article Title " . $x ;
  }
  
  // List them all
  foreach($magazines as $magazine){
      echo $magazine . " has these articles: &lt;br&gt;";
      foreach($articles[$magazine] as $article)
          echo $article . "&lt;/br&gt;";
  }
  ?&gt;
  </code></pre>