In this article, you will learn while loop in PHP. The while keyword in PHP is used to create a while loop and is also used to set the looping condition of a do…while.
examples of the WHILE keyword
Example 1. In this example, we use a while loop to print numbers from 1 to 5.
<?php
$i = 1;
while($i <= 5) {
echo $i;
echo "<br>";
$i++;
}
?>