While
<?php
$count = 1;
while ($count <= 12) {
echo $count . "<br />";
$count++;
}
?>
Do while
Similar to a while loop with the exception that the code block is executed before the loop repeats. Note how it does not keep executing after the code realizes $number is not greater than 100 and less than 200.
<?php
$number = 1;
do {
echo $number . "<br />";
$number ++;
} while (($number > 100) && ($number < 200));
?>
For (each)
Like the While statement but without having to declare variables outside the loop. The For statement includes the variable which you are incrementing in one line of code.
<?php
for ($count = 1; $count <= 12; $count++) {
echo $count . "<br />"
}
?>


Fri, Jul 25, 2008
PHP