CHAPTER 4Working with Arrays

If you have worked with PHP 4 or another scripting language, then you have almost certainly worked with arrays—the idea of lists or collections of values is central to programming in general, and PHP is no exception. If you are not already familiar with arrays, you should flip back to Lee Babin's Chapter 1 and get up to speed on just what an array is. Here we will just remind you that the simple definition of the word array is "a collection or list of values."

However, when using arrays in PHP, it is important to remember that PHP lumps together two different sorts of constructs under the same name: ordered lists and unordered lists. Ordered lists are often referred to in PHP as indexed arrays, in which each value ...

Get PHP 5 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.