PHP Tutorial
The do...while statement will execute a block of code at least once - it then will repeat the loop as long as a condition is true.
It executes the code at least one time always because the condition is checked after executing the code.
do {
code to be executed;
} while (condition is true);
In a do...while loop the condition is tested AFTER executing the statements within the loop.
Let's put these syntax into real use.
<?php
$x = 10;
do {
echo "Number = $x <br>";
$x++;
} while ($x <= 20);
?>
This will produce the following result −
Number = 10
Number = 11
Number = 12
Number = 13
Number = 14
Number = 15
Number = 16
Number = 17
Number = 18
Number = 19
Number = 20