From the course: PHP for Non-Programmers

Unlock the full course today

Join today to access over 25,200 courses taught by industry experts.

Performing a task more than once

Performing a task more than once - PHP Tutorial

From the course: PHP for Non-Programmers

Performing a task more than once

- [Instructor] Sometimes you want to repeat a task until it's done. Practically speaking, this could be continuously incrementing a number or printing all of the elements of an array. The control structures you've seen so far focus on making a decision and then executing the code once before moving on. But there's a different control structure if you want to repeat a task some number of times. Loops. A loop will execute some specific code as long as a condition is true. You can imagine the structure of a loop like this. While some condition is true, execute the code. If some condition ever becomes false, move on. There are three different types of loops in PHP. We'll be looking at two in this course. But they all have two important components for you to keep in mind. All loops have a true/false condition much like with if statements. And they also have a statement that moves the condition towards being false. For…

Contents