PHP Do While Loop

Do While loop looks similar to While loop but it is different loop as compared to while loop because here the given condition is checked at the bottom of the loop.

It is to be noted that do while loop is guaranteed to be executed at least one time.


do {
   //code to be executed;
} while (condition is true);

PHP Do While Loop Example

$watchesLeft = 3;
  echo "There are $watchesLeft watches left. < br / >
} while($watchesLeft > 0);

This will produce following result

There are 3 watches left.
There are 2 watches left.
There are 1 watches left.