title: PHP Foreach array to table display
body: <p>I have an array <code>$day</code> and want to display this array in table form (I'm working with CI)</p>
  
  <pre><code>Array ( 
  [START_EXECUTION] =&gt; 
      Array ( 
          [0] =&gt; 27-OCT-14 
          [1] =&gt; 28-OCT-14 
          [2] =&gt; 29-OCT-14 
            ) 
  [NUM_OF_POPULATION] =&gt; 
      Array ( 
          [0] =&gt; 6171 
          [1] =&gt; 6990 
          [2] =&gt; 6882 
            ) 
  [SUM_AMOUNT] =&gt; 
          Array ( 
          [0] =&gt; 361154716.01 
          [1] =&gt; 409210099.77 
          [2] =&gt; 407191552.71 
            ) 
  )
  </code></pre>
  
  <p>Here is my code that I use in view :</p>
  
  <pre><code>&lt;?php
  if(count($day)&gt;0){
      print_r($day);
      foreach($day as $index =&gt; $dt1_element){    
  ?&gt;        
      &lt;table class='table'&gt;
          &lt;tr&gt;
          &lt;td&gt;&lt;?= $index ?&gt;&lt;/td&gt;
          &lt;/tr&gt;        
  &lt;?php
      foreach($dt1_element as $row){        
  ?&gt;
          &lt;/tr&gt;
          &lt;td&gt;&lt;?= $row ?&gt;&lt;/td&gt;
  &lt;?php
      }
  ?&gt;
          &lt;/tr&gt;
  &lt;?php
      }
  ?&gt;
      &lt;/table&gt;
  &lt;?php
      }
  ?
  </code></pre>
  
  <p>But what I get is like this :</p>
  
  <pre><code>START_EXECUTION
  27-OCT-14
  28-OCT-14
  29-OCT-14
  
  NUM_OF_POPULATION
  6171
  6990
  6882
  
  SUM_AMOUNT
  361154716.01
  409210099.77
  407191552.71
  </code></pre>
  
  <p>The result should be :</p>
  
  <pre><code>START_EXECUTION   NUM_OF_POPULATION   SUM_AMOUNT
  27-OCT-14         6171                361154716.01
  28-OCT-14         6990                409210099.77
  29-OCT-14         6882                407191552.71
  </code></pre>
  
  <p>Kindly show me the correct foreach to get the desired result. Thank you</p>