Using foreach() with numeric arrays : foreach « Statement « PHP






Using foreach() with numeric arrays

 
<?
$dinner = array('A',
                'B',
                'C');
foreach ($dinner as $dish) {
    print "You can eat: $dish\n";
}
?>
  
  








Related examples in the same category

1.Foreach Demo
2.Looping through an Enumerated Array
3.Array element order and foreach()
4.Iterating through a multidimensional array with foreach()
5.Modifying an array with foreach()
6.Using foreach() to Iterate Through an Array
7.Displaying the contents of an array using a loop
8.Iterating Through Object Properties
9.Implementing the traversable Iterator