CodeIgniter Forums

Full Version: parse three array with foreach
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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.