Foreach Demo : foreach « Statement « PHP

Foreach Demo

<title>Foreach Demo</title>

$list = array("A", "B", "C", "D", "E");

print "<ul>\n";
foreach ($list as $value){
  print " <li>$value</li>\n";
} // end foreach
print "</ul>\n";



Related examples in the same category

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