PHP Do-While Loop
The do-while loop is used to execute a block of code while a condition is true.
Syntax
do {
// code to be executed
} while (condition);
Example of PHP Do-While Loop
<?php
$i = 0;
do {
echo "The number is $i\n";
$i++;
} while ($i < 5);
?>
Output:
The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
Explanation: This example demonstrates the use of the do-while loop in PHP. The loop executes 5 times, and the value of $i is printed each time.