title: For loop inside foreach loop php
body: <p>I am successfully fetching students name and subject dynamically ( generate pdf ) in codeigniter.
  Now I want to fetch student record to get result like the following:</p>
  
  <pre><code>Student name   Drawing    Math   Computer
  A               89        66     92         
  B               65        72     83 
  C               62        71     86 
  D               78        73     83
  E               82        91     82
  </code></pre>
  
  <p>I am getting student name vertically, now I want student name horizontally like above array, current array is</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
      (
          [oral] =&gt; 30
          [Written] =&gt; 20
          [Drawing] =&gt; 10
          [Listening] =&gt; 70
      )
  
      [1] =&gt; Array
      (
          [oral] =&gt; 20
          [Written] =&gt; 60
          [Drawing] =&gt; 10
          [Listening] =&gt; 40
      )
  
      ...
  )
  </code></pre>
  
  <p>Here is the code that generates view, where student record is shown vertically:</p>
  
  <pre><code>&lt;?php foreach ($studentrecord as $rec) {?&gt;
      &lt;tr&gt;
          &lt;td width="200px"&gt;&lt;span&gt;&lt;?php echo $rec['StudentName'];?&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;&lt;span&gt;&amp;nbsp;&lt;?php ?&gt;&lt;/span&gt;&lt;/td&gt;
  
          &lt;td&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;?php  } ?&gt;
  </code></pre>
  
  <p>Now I want to fetch marks horizonaly, how do I do that?</p>