EN49

Page 396

Chapter 80: SPL data structures Section 80.1: SplFixedArray Difference from PHP Array PHP's default Array type is actually implemented as ordered hash maps, which allow us to create arrays that consist of key/value pairs where values can be of any type and keys can be either numbers or strings. This is not traditionally how arrays are created, however.

So as you can see from this illustration a normal PHP array can be viewed more like an an ordered set of key/value pairs, where each key can map to any value. Notice in this array we have keys that are both numbers and strings, as well as values of different types and the key has no bearing on the order of the elements. $arr = [ 9 => "foo", 1 => 4.2, "bar" => null, ];

GoalKicker.com – PHP Notes for Professionals

383


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.