Iterating through a numeric array with for() : for loop « Statement « PHP
- PHP
- Statement
- for loop
Iterating through a numeric array with for()
<?
$dinner = array('A',
'B',
'C');
for ($i = 0, $num_dishes = count($dinner); $i < $num_dishes; $i++) {
print "Dish number $i is $dinner[$i]\n";
}
?>
Related examples in the same category