

Here, you know the size of an array so you can create a for loop that executes a block of code 5 times. For example, you have a fixed array of 5 elements and you want to print arrays elements. Increment/Decrement: It is the ratio to increment or decrements a loop.įor loop is used when you exactly know how many times of iterations are needed to complete a job. Example 1: Program to increment various letters and print it. Termination: It is the point when loop gets terminated.ģ. The only point of difference being decrement () operator doesn’t work the same in letters as it does in numbers.
Initialization: It is the starting point of a loop.Ģ. PHP Change language: Submit a Pull Request Report a Bug ¶ PHP C : null null 1These include for loop, while and do while and the foreach loop.

The loop allows you to iterate through list or array and allows you to execute a block of codes multiple times.ġ. The for loop in PHP PHP supports different types of loops to iterate through a given block of code. If put before the variable, the increment/decrement operation is done to the variable first then the result is returned. If the condition is true, the code block inside the loop will be executed.If the condition is false, the loop will be terminated. condition : This is the second step of the for loop. It is used to initialize a counter variable. WHAT IS LOOP CONSTRUCT IN PHP? Loop means, repeating a job until condition fails. initialization : This is the first step of the for loop.
