<?php
$fruit = array( "Banana","Apple", "Plum");
foreach ($fruit as $fruit_name)
{
echo "$fruit_name<br/>\n";
}
?>
The above will display:
Banana
Apple
Plum2. For each bring two value in the array
<?php
$fruitColours = array("Banana" => "Yellow","Apple" => "Green","Plum" => "Purple");
foreach ($fruitColours as $fruit_name => $fruit_colour)
{
echo "$fruit_name is $fruit_colour<br/>\n";
}
?>
The above will display:
Banana is Yellow Apple is Green Plum is Purple