While

A while loop is the simplest kind of loop in PHP: it keeps running as long as its condition remains true. You give it a condition — usually something like $i < 6 — and PHP checks that condition before every iteration. If it’s still true, the loop runs again. If it’s false, the loop stops.

Inside the loop, you usually update something (like $i++), otherwise it’ll loop forever. The condition doesn’t need to be a number — it can be anything that evaluates to true or false, like whether a file exists, whether a user is still logged in, or whether a process has finished.

You can interrupt the flow with break, which stops the loop early, or continue, which skips the current iteration and jumps to the next one. PHP also allows an alternative syntax with endwhile, which is mostly used in template-like code (like inside WordPress themes).

And you can adjust your increment however you want — for example, jumping by tens instead of ones.