CodeIgniter Forums
parse three array with foreach - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: parse three array with foreach (/thread-59398.html)



parse three array with foreach - El Forum - 09-30-2013

[eluser]masentinel900[/eluser]
Hello Guys!!
I'm working with CI for to do a pdf report, so I need to introduce some values in a html form (This is dinamically because there inputs according days).

The Idea is to do a report that describes the activities and foods for each one day. is like a schedule.

So the final result will some like ::

Day 1 - 28 september.
Activities: The activity according this day, this activity is typed from the html form.
Food: The same here.

Day 2 - 29 september.
Activities: and so on.
Food: And so on.

So I have two ways to do it.

The first option is to bring the three arrays from the html view
The second option is to bring only two arrays (activities and food) and the day bring it from the DB.

In this moment I have this::

Code:
$activity = $this->input->post('Activity');
$food = $this->input->post('Food');
$cActi = count($activity );
for($i=1; $i<=$cActi;){
  foreach(array_combine($activity , $food ) as $row => $key){
   $mpdf->WriteHTML('<tr><td>'.$i++. ' ' .'</td></tr>');
   $mpdf->WriteHTML('<tr><td>'."Activities: " . $row .'</td></tr>');
   $mpdf->WriteHTML('<tr><td>'."Food: " . $key .'</td></tr>');
   $mpdf->WriteHTML('<tr><td><br /></td></tr>');
   }
  }

Here all works perfect, but the problem Is that I still I don't have added the date. And I don't know how process three arrays.