Last updated on December 13, 2015
PHP while loops execute a block of code while the specified condition is true.In PHP, we have the following while looping statements:
while – loops through a block of code as long as the specified condition is true
do…while – loops through a block of code once, and then repeats the loop as long as the specified condition is true
while Loop
while (condition is true) { code to be executed; }
do…while Loop
The do…while loop will always execute the block of code once, it will then check the condition, and repeat the loop while the specified condition is true.
do { code to be executed; } while (condition is true);