title: Dynamicaly generated PHP multidimensional associative array
body: <p>The simplified version of my code is below, I will eventually assign values to the number of people (this is from an sql table). I'm wondering what's wrong with my multidimensional array. It seems like everything should be associative when I'm making it, but the array that gets spit out is not what I'm looking for, because the first key isn't a value of the distance, its just an incrementing number. How do I make an array that allows me to use this as the key? (Please note that in this example I don't know how many distances there are nor the amount of people in each distance.) </p>
  
  <pre><code>&lt;?php
  $speed = array("ran", "walked");
  $distance = array(15,10,3,5,1,2);
  
  foreach ($distance as $key) {
    foreach ($speed as $secondarykey) {
      $array[$key][$secondarykey] = "number of people";
    }
  }
  
  print_r(array_values($array));
  
  unset($array);
  
  ?&gt;
  </code></pre>
  
  <p>My array that I get back looks like this:</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
      (
          [ran] =&gt; number of people
          [walked] =&gt; number of people
      )
  
  [1] =&gt; Array
      (
          [ran] =&gt; number of people
          [walked] =&gt; number of people
      )
  
  [2] =&gt; Array
      (
          [ran] =&gt; number of people
          [walked] =&gt; number of people
      )
  
  [3] =&gt; Array
      (
          [ran] =&gt; number of people
          [walked] =&gt; number of people
      )
  
  [4] =&gt; Array
      (
          [ran] =&gt; number of people
          [walked] =&gt; number of people
      )
  
  [5] =&gt; Array
      (
          [ran] =&gt; number of people
          [walked] =&gt; number of people
      )
  
  )
  </code></pre>
  
  <p>It seems like there is something simple that I'm just not getting about how multidimensional arrays work. Any help is appreciated.</p>