what types of loops exist in php?

Loops in PHP are used to execute the same block of code a specified number of times. PHP supports following four loop types.

for − loops through a block of code a specified number of times.

while − loops through a block of code if and as long as a specified condition is true.

do...while − loops through a block of code once, and then repeats the loop as long as a special condition is true.

foreach − loops through a block of code for each element in an array.
 
for − loops through a block of code a specified number of times.
while − loops through a block of code if and as long as a specified condition is true.
do...while − loops through a block of code once, and then repeats the loop as long as a special condition is true.
 
PHP supports four loop types.
for --> loops through a block of code a specified number of times.
while --> loops through a block of code if and as long as a specified condition is true.
do - while --> loops through a block of code once, and then repeats the loop as long as a condition is true.
 
Back
Top