Hi,
or . . . do: This is basically shorthand for a while loop where the condition is whether a particular variable has yet to reach a certain value. Each time the loop is executed the variable is generally incremented or decremented. This kind of control statement is useful when you want to count through a series of numbers or objects, or repeat a set of statements of particular number of times. For example,
PHP Code:
$sum = 0;
for ( $a = 1; $a <= 10; $a++ )
{
$sum += $a;
}
echo "Sum of numbers from 0 to 10 equals $sum.";
// The for loop is just shorthand for the following while loop:
$a = 1;
while ( $a <= 10 )
{
$sum += $a;
$a++;
}