The foreach statement is new to us. JavaScript doesn't have this function. It loops over the array given by the parameter passed to the function. On each loop, the value of the current element is assigned to $value and the array pointer is advanced by one - so on the next loop, you'll be looking at the next element.

Syntax
foreach (array as value)
{
code to be executed;
}


The following example demonstrates a loop that will print the values of of the given array:

<html>
<body>
<?php
$arr=array("one", "two", "three");
foreach ($arr as $value)
{
echo "Value: " . $value . "<br />";
}
?>
</body>
</html>

(from w3schools.com)

 

Table of Contents