title: Rearrange array
body: <p>Array starts like this:</p>
  
  <pre><code>Array ( 
    [SMART Board] =&gt; Array ( [0] =&gt; sb1 [1] =&gt; sb2 [2] =&gt; sb3 ) 
    [Projector] =&gt; Array ( [0] =&gt; pr1 [1] =&gt; pr2 [2] =&gt; pr3 ) 
    [Speakers] =&gt; Array ( [0] =&gt; sp1 [1] =&gt; sp2 [2] =&gt; sp3 ) 
    [Splitter] =&gt; Array ( [0] =&gt; spl1 [1] =&gt; spl2 [2] =&gt; spl3 ) 
    [Wireless Slate] =&gt; Array ( [0] =&gt; ws1 [1] =&gt; ws2 [2] =&gt; ws3 ) 
  )
  </code></pre>
  
  <p>The keys are used as my table columns titles. Their individual arrays are to carry the column information.</p>
  
  <p>I have split it up even further with <code>array_slice</code> and <code>array_merge_recursive</code> to look pretty as 2 arrays - 1 holds the column names, the other looks like this:</p>
  
  <pre><code>Array ( 
    [0] =&gt; sb1  
    [1] =&gt; sb2  
    [2] =&gt; sb3  
    [3] =&gt; pr1  
    [4] =&gt; pr2  
    [5] =&gt; pr3  
    [6] =&gt; sp1  
    [7] =&gt; sp2  
    [8] =&gt; sp3  
    [9] =&gt; spl1  
    [10] =&gt; spl2  
    [11] =&gt; spl3  
    [12] =&gt; ws1  
    [13] =&gt; ws2  
    [14] =&gt; ws3  
  )
  </code></pre>
  
  <p>However, when trying to write the table I'm getting keys 0, 1, 2 as the column data, then row break then 3, 4, 5 then row break... etc. </p>
  
  <p>I need it to be 0, 3, 6, 9, 12 row break 1, 4, 7, 10, 13 row break etc...</p>
  
  <p>How can I either rearrange my array to allow for this, or rewrite how the data goes into the table so that the correct information lines up with the appropriate column?</p>
  
  <pre><code>foreach(unserialize($dl-&gt;data) as $data){
  
      //first 3 are specialinstructions, system, and room
      $uniques = array_slice($data,0,3);
  
      $rows = array_slice($data,3);
      $rows2 = array_merge_recursive($rows2, $rows);
  
      //get the specialinstructions, system, and room
      foreach($uniques as $unique){
          echo $unique."&lt;br/&gt;";
      }///foreach uniques
  
      echo "&lt;br&gt;";
  
  }///foreach unserialized
  
  $numberofrooms = count($rows2[key($rows2)]);
  $numberofproducts = count($rows2);
  print_r($rows2);
  
  unset($rows);
  
  //write the individual rows
  foreach($rows2 as $header=&gt;$rowset){
  
      $headers[] = $header;
  
      foreach($rowset as $row){
  
          $rows[] = $row;
  
      }//foreach rowset
  
  }//foreach rows2
  
  echo "&lt;p&gt;";
  print_r($rows);
  
  echo '&lt;table class="data-table"&gt;
            &lt;caption&gt;DL&lt;/caption&gt;
  
            &lt;thead&gt;&lt;tr&gt;';
  foreach($headers as $header){
      echo "&lt;th&gt;".$header."&lt;/th&gt;";
  }
  echo '&lt;/tr&gt;&lt;/thead&gt;';
  echo '&lt;tbody&gt;';
  $i = 0;
  foreach($rows as $row){
      if($i == 3 || $i == 0){
          echo "&lt;tr&gt;";
          $i = 1;
      }
      echo '&lt;td&gt;'.$row.'&lt;/td&gt;';
      if($i == 2){
          echo "&lt;/tr&gt;";
      }
      $i++;
  }
  echo '&lt;/tbody&gt;&lt;/table&gt;';
  </code></pre>