title: Store values in multidimensional array using php
body: <p>I am using a <code>while loop</code></p>
  
  <pre><code>      $i = 0;
        $arr = array();
        while($get_key1 = mysql_fetch_assoc($get_key))
        {
          $busid = $get_key1['busid'];
          $get_key2 = mysql_query("select * from `route` where `busid`='$busid'") or die(mysql_error());
  
          while($get_key3 = mysql_fetch_assoc($get_key2))
          {
              $arr[$i] = $get_key3['routid'];
              echo "&lt;pre&gt;";
              print_r($arr);
          }
          echo "&lt;hr/&gt;";
          $i++;
        }
  </code></pre>
  
  <p>This inner loop gives three values, <code>1,3,4</code> and when itereates again then it gives values <code>1,4</code> I want to create a multi dimensional array as </p>
  
  <pre><code>array(array(1,3,4),array(1,4))
  </code></pre>
  
  <p>but the above code gives the result as : </p>
  
  <pre><code>Array
  (
      [0] =&gt; 1
  )
  
  Array
  (
      [0] =&gt; 1
      [1] =&gt; 3
  )
  
  Array
  (
      [0] =&gt; 1
      [1] =&gt; 3
      [2] =&gt; 4
  )
  
  Array
  (
      [0] =&gt; 1
      [1] =&gt; 3
      [2] =&gt; 4
      [3] =&gt; 1
  )
  
  Array
  (
      [0] =&gt; 1
      [1] =&gt; 3
      [2] =&gt; 4
      [3] =&gt; 1
      [4] =&gt; 4
  )
  </code></pre>
  
  <p>How can I store the values through while loop in multi dimensional array</p>