December 2001
Intermediate to advanced
520 pages
13h 42m
English
An array is a special type of variable that can act like a list or like a table in a spreadsheet program. Because of their power and flexibility, arrays are widely used in advanced PHP programming. I'll run through a couple of the strongest array functions now.
New to PHP 4 is the foreach construct, designed to more easily access all of an array's keys and values. Assuming you have an array of name $array, you can access every element using the following code:
foreach ($array as $key => $value) {
// Code
}
I tend to use foreach when dealing with arrays and will do so in this book. If you are running an earlier version of PHP, you'll need to rewrite the above code as:
reset ($array); while (list($key, $value) = each ($array)) { // Code ...Read now
Unlock full access