How do you make a while loop in php?

The while loop - Loops through a block of code as long as the specified condition is true.

The PHP while Loop

The while loop executes a block of code as long as the specified condition is true.

Syntax

while [condition is true] {
  code to be executed;
}

Examples

The example below displays the numbers from 1 to 5:

Example

Try it Yourself »

Example Explained