HomePHP Page 5 - PHP 101 (part 3) - Chocolate Fudge And Time Machines
Anyone For Apple Pie? - PHP
After teaching you the fundamentals of form processing, PHP 101 returns with an explanation of WHILE, FOR and FOREACH loops, those PHP constructs that can save you hours of unnecessary HTML coding. Also included: array variables, the auto-increment operator, and some yummy desserts.
PHP offers one more type of loop, the "foreach" loop, which is designed specifically for use with array variables. Logic would suggest that we explain array variables before we attempt to teach you the "foreach" loop...and you know what slaves we are to logic!
Thus far, the variables you've used contain only a single value - for example,
$i = 0
However, array variables are a different kettle of fish altogether. An array
variable can best be thought of as a "container" variable, which can contain one or more values. For example,