April 2026
Intermediate
1009 pages
34h 15m
English
With loops, you execute statements several times in succession. PHP knows four types of loops, which are also quite common in other programming languages.[ 40 ] You will now get to know three of the four loops. The last one, foreach, is mainly used with objects and arrays. It is discussed in Chapter 11.
The for loop is the most convenient of all loops. It already has three arguments to control the loop behavior:
for (start statement; condition; run statement) { statements; }
And this is how it works:
The start statement is executed once at the beginning.
PHP then checks the condition.
If the condition is met, then the interpreter executes the statements within the loop. If it does not apply, the loop is exited ...
Read now
Unlock full access