Learn web design and programming with our free video and text tutorials.
Web Designer? Design and market your own professional website with easy-to-use tools.
PHP foreach loops are used to loop through arrays.
<?php
$arr=array(1, 2, 3, "four", "five", "six");
foreach ($arr as $number)
{
echo "Number: " . $number . "<br />";
}
?>
The code above outputs:
Number: 1
Number: 2
Number: 3
Number: four
Number: five
Number: six