PHP loves its arrays. Arrays are the uber-data structure. They’re a list, a map, a stack, a queue, everything in one! Which is the problem.

Modern PHP grossly over-uses arrays. In most cases there are better options today, and when you find yourself reaching for “oh I’ll just make this an associative array”, stop. An extra 60 seconds of thought and code will often give you a more readable, faster, more memory-efficient, more flexible alternative. Classes, iterables, and collections can and should replace arrays in most of your day to day coding.

This talk will go through what PHP arrays actually are (hint: they are not, in fact, arrays at all), why they’re so problematic, and what to do instead. By the end, you should find yourself (almost) never reaching for arrays to solve a problem.


Comments are closed.

Arjan Kleene at 21:52 on 14 May 2020

Interesting talk with lots of options for arrays, and a comparison (memory/time) between arrays and objects.

Fun talk with some technical insight an good hand on tipps - even though I did not need any convincing to begin with ;)

Top Secret at 22:35 on 14 May 2020

Perfectly balanced talked. Interesting insights and explanations, why arrays behave as they behave. And perfect alternative and better implementation suggestions.
Just the generator part went a little too far.