DEV Community

Discussion on: Things you probably don't know about PHP arrays

Collapse
 
hbgl profile image
hbgl • Edited

Arrays are actually implemented with hash tables.

Internally, PHP has the notion of packed arrays. These are arrays that have consecutive integer indices, e.g. ['foo', 'bar', 'baz'], with some additional caveats. The interesting thing is, that they are not implemented with a hash table, but with a contiguous list. I thought this would be interesting to know because it can give you a performance boost in some applications.