PHP For

for loop through a block of code until a certain condition is met.

Below the syntax of for loop

  1. for (initialization; condition; increment/decrement){
  2. //code to be executed
  3. }
for ($i = 1; $i <= 5; $i++) 
echo "$i<br/>";

Output:

1
2
3
4
5