//set the counter variable, counter condition, and counter increment.
//counter variable: start the counter variable at zero
//condition: run the code (loop) while counter variable is less than 50
//counter increment: add one to the counter everytime you loop
for($counter=0 ; $counter<50; $counter=$counter+1)
{
echo "This is loop number ".$counter;
}
The above code starts the counter at zero, checks the condition, runs the code, then increments the counter variable. The code will continue looping until the counter variable evaluates to false. Code executions stops at that time.
Here's another example:forloops.php
|