Repeats a block of code.
The for statement repeats a block of code until a condition has been met. Before the first execution of the block, an initialization statement is executed. At each start of execution of the code block, an incrementation statement is executed. The for statement is often used to repeat something an exact number of times that is known before the execution of the code.
<?php
$j = 0;
for ($i = 0; $i < 10; $i++) {
$j += $i;
print "$j ";
}
?>
0 1 3 6 10 15 21 28 36 45
This for loop adds an increasing i to j 10 times.