Membership
Main Menu
Forum Boards
Stats
- 18 tutorials
- 72,339 members
- 696,883 forum posts
- 11 blog posts
Tutorials
PHP Loops
Views: 21570
The For Loop
We used the for loop in our example on how loops work, so you should already have a decent understanding about this loop. The only thing to really understand about the for loop, is that it is the "strictest" loop out of the bunch. It needs a set starting point, and a set ending point. It's useful if you know exactly how many iterations you are dealing with, simple as counting from 1 to 10.
As shown previously:
for (initialization; condition; iteration) {
instruction
}
The condition will always be evaluated before the instruction is complete, and the instruction will be executed before the value is iterated.
initialization -> condition -> instruction -> iteration -> condition -> instruction -> iteration ...
