PHP For Loops
for loops execute a given code block until a certain condition is true.
Syntax
<?php
for (init; condition; increment) {
code to be executed;
}
?>
Initialization happens the first time the loop is run. It is used to initialize variables or perform other actions that are to be performed before the first execution of the body of the loop. The Condition is evaluated before each execution of the body of the loop; if the condition is true, the body of the loop will be executed, if it is false, the loop is exited and program execution resumes at the first line after the body of the loop. increment specifies an action that is to be performed after each execution of the loop body.
Example
<?php
for($i = 0; $i < 5; $i++) {
echo ($i . "<br />");
}
#Output: 0 1 2 3 4
?>


