While Loops
<?php $num = 1;
while ( $num <=10 ) { print $num . " ";
$num++;
} ?>
In the example above, we need to make sure that we have the $num++ in our code. If we don't increase our number each loop it will never finish!
For Loops
<?php
for ($num=1; $num <= 10; $num++ )
{
print $num . " ";
}
?>
Again in this example using a for loop, we need to make sure that we use $num++ so that we are actually changing the number, and the loop has a chance to meet it's condition and end.
ForEach Loops
Since a ForEach loop uses data from an array, than the condition for ending the loop is met when all of the data in the array has been used. For this reason you don't have to worry about it being recursive, as long as you don't accidently redefine the array on every line!

