PHP foreach loop

A foreach loop can be used in PHP  with an array instead of a counter. If an array contains 5 pieces of data, then the foreach loop would execute 5 times.

A foreach loop is phrased like this: foreach (array as value) { what to do; }

Here is an example of a foreach loop:

$a = array(1, 2, 3, 4, 5);
foreach ($a as $b)
echo $b;
echo (‘<br/>’);