In this tutorial, you shall learn about loops in PHP, different loop statements available in PHP, and tutorials for each of them.
Loops
In PHP, loop statements are used to execute a block of statements repeatedly in a loop based on a condition or for each element in a given collection.
There are four looping statements in PHP. In the following tutorials, we cover them with detailed explanation and examples for each of them.
- PHP While Loop PHP While loop executes a block of code in a loop as long as the given condition evaluates to true.
- PHP Do-While Loop PHP Do-While loop executes a block of code, and then repeats the loop as long as the given condition evaluates to true.
- PHP For Loop PHP For Loop executes a block of code in a loop as long as the given condition is true. For loop differs with the While loop by the initialization and updation parts in the syntax.
- PHP foreach PHP foreach loop executes a block of code for each element in the a collection.
Conclusion
In this PHP Tutorial, we learned about different loop statements, and examples for each of them.