PHP TutorialLesson 19Free preview
PHP Loops
This lesson is part of PHP · All levels
Summary
A loop causes a program to run the same block of code over and over again without rewriting it. PHP provides for, while, do-while, and foreach with their respective characteristics. You also learn to break to stop the loop and continue to skip one iteration.
Key points
- For is used when the number of repetitions is known
- While checking the condition before the block, do-while checking after the block is executed
- Foreach specifically for repeating array elements
- Break stop the loop, continue jumping to the next iteration
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.