When you need the same block of code to be executed over and over again .

In PHP, we have the following looping statements :


1. while-
loops through as long as the given condition is true

2. do...while-
loops through the code once, and then repeats the loop as long as the given condition is true

3. for-
loops through a the code a given number of times

4. foreach-
loops through the code for each element in a collection





Related Articles