For Loops in PHP
When to Use 'For'

Great job! for loops are great for running the same code over and over, especially when you know ahead of time how many times you'll need to loop. (There are other kinds, such as while and do/while loops, that we can use when we don't know ahead of time how many times we'll need to loop, but we'll cover those in a later lesson.)

There's also a special kind of loop called a foreach loop that we can use to update or print out every element in a list—for example, an array. Let's cover foreach next!


Click "Save & Submit Code" to continue.

View Preview