A for loop is designed to do something a set number of times.  Create a new page called phpfor.php and put this inside the block of PHP:

for($i=0; $i<10; $i=$i+1){
    echo "<p>Hello number $i</p>";
}

This will loop through ten times and could be used if you wanted to always list exactly ten things on a page or to create ten things of any type.  You may not use it much once you know SQL.

The condition (the bit inside normal brackets) is made up of three parts meaning:

  1. start with a variable i containing zero ($i=0)
  2. continue looping until the value in the variable is 10 or more and then stop ($i<10)
  3. each time through the loop add one to the value stored in the variable ($i=$i+1)

This loop will runt he first time with $i being 0.  Then it adds 1 so the next time it loops you see that number.  When it reaches 9 it still loops again but at 10 it stops.  You do not see the number ten as the code inside the loop does not run.

A for loop could also be used to loop through an array of data although there is an easier and more reliable way coming up next, Try it anyway in phpfor.php by adding this code under the existing loop:

$george[0]="George";
$george[1]="Harrison";
$george[2]="Guitar";
for($i=0; $i<3; $i++){
    echo "<p>$george[$i]</p>";
}

Note that in this loop $i=$i+1 has been replaced by $i++.  Both work exactly the same way (add one to the value in $i) but the second is a kind of shorthand so is preferred by most people.

Other conditions

You could start with $i being 10 and work down to zero ($i=10;$i>0;$i--).  You can also use <=, =>, == or !=.  You could also change the value by more than one ($i=$i-2) or use multiplication or division to change it.  The $i++ is the most normal though.