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 ...

Get Zend PHP Certification Study Guide 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.