Sunday, April 2, 2017

How To Use foreach In PHP


<?php

$food = array('Healthy'=>array('Salad', 'Milk', 'Coconet', 'Ground_nut'), 
              'Unhealthy'=>array('Alcohol', 'Beer', 'Ice_cream'));

foreach($food as $element => $inner_element){
  echo '</br><strong>'.$element.'</strong></br>';

foreach($inner_element as $item){
  echo $item.'</br>';
}
}

?>

No comments:

Post a Comment