Loops let you run the same block of code multiple times. PHP supports several types of loops for different situations.
for
— runs a block of code a specific number of times.while
— runs as long as a condition is true.do...while
— runs at least once, then repeats if the condition is true.foreach
— loops through each item in an array.\n
inside echo
statements to create line breaks in your output.