PHP Control Structures
Repeating Statements with Loops
Throughout our daily routines we repeat certain actions over and over again to accomplish a task. A very basic example would be the steps we take when brushing our teeth (brush, rinse, gargle) and repeat these steps until we are satisfied with the results. We can apply this same analogy to a loop construct, which is used to execute a statement or block of statements repeatedly until a condition is satisfied. Since computers are very good at repeating operations, we can use loops to perform repetitive tasks that would otherwise be very time consuming and boring.
Similar to other programming languages PHP offers two types of loops: conditional loops, which are repeated an indefinite number of times until a condition is met and iterated or counter loops, which are repeated a fixed number of times.
