Iterative Control Structures
Iterative control structures, including do-while, for, foreach, and while loops, provide the programmer with a key tool by enabling a program to repeat a set of instructions a specified number of times or until a condition is met.
There are different structures because you can have different purposes when you want to step through data repeatedly. Sometimes you want to do it until a condition is met, as is accomplished with the for and do-while loops. On occasion you want to gate entry to an iterative structure with a condition, which is what the while loop does. In the case of a hash table or hash map, which manages a key-to-value index, PHP provides a special iterative structure—the foreach loop.
In the following ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access