PHP

Array Iteration

<?php
   for ($i = 0; $i < count($array); ++$i) {
      print $array[$i];
   }
?>

<?php
   while (list($var, $val) = each($array)) {
      print "$var is $val\n";
   }


   foreach($array as $val) {
     print $val;
   }

   foreach ($array as $key => $val) {
     print "$key = $val\n";
   }
?>

José M. Vidal .

15 of 33