Foreach Loop

Foreach loop acts only on arrays and acts similar to For loop. Difference is you don’t have to define an incrementer and increment it. There is also no condition to evaluate. It would run for each item in the array and won’t run at all if the array is empty.


foreach (array as value)  {
block of codes


$array = array(1,2,3,4,5);
foreach($array as $value)
echo $value.” t”;


1 2 3 4 5