How to create a while loop in PHP In this post snipped I’ll show you an easy way to create simple while loops and multiple or nested while loops. Scenario Create a counting script that stops once it reaches 10 and it also prints the count to the user once the execution has finished. Solution