Chapter 4. Arrays

AS MENTIONED BRIEFLY IN CHAPTER 1, “The Basics of PHP,” arrays are containers in which an arbitrary number of other data elements can be stored. If you’re coming to PHP from a language such as C, the concept of array that the former adopts will be a bit different from what you’re used to.

Think of an array as a “collection” of heterogeneous values, each uniquely identified by an arbitrary key, which can itself be either an integer numeric or string value. Thus, for example, an array could contain a floating-point value, a string, a Boolean, and even another array.

Although PHP will automatically provide a key for each value of the array if you insert them sequentially, there doesn’t necessarily have to be any correlation between ...

Get Zend PHP Certification Study Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.