PHP loop PHP – While loop:
while loops check for the expression. If it is evaluated to true, the subsequent statement is executed.Example:
$ x=5;PHP – For loop:
The for loops are similar to the for loop in C.
For ($x=1; $x<10l; $x++)
PHP for each – PHP for each works best only for arrays.Syntax:
here, the foreach loops over the array given by array_expression. On each loop, the value of the current element is assigned to $value and the internal array pointer is advanced by one.
array_expression as $value
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value)
$value = $value * 2;