Don't D(is)S My Arrays, Bro!

Don't D(is)S My Arrays, Bro!

"All hail King Array! Huzzah!"

That is the chant I heard at my PHP coronation ceremony. As a PHP developer, and especially as a Drupal 7 PHP developer, I've used PHP's array to create actual "arrays" but also what you'd call a "set" or "dictionary" in other languages. To an outsider looking into PHP, not having great data structure support at the core of a language seems like a code smell and a potential deal-breaker. 

There were more data structures introduced in the Standard PHP library, but it was ugly and most people didn't like it. With the PHP 7 renaissance, I've seen pushes towards adding more semantic, object-oriented data structure support in PHP with extensions like, and I hope those pushes take off. You can use that extension now when writing your code since there are polyfills for the data types. 

In this session we will:

  • Go over data structures in general
  • Look at other language data structures
  • Look at the use of SPL in D8
  • See example code using the DS extension

...and in the end, I'll tell you that this is all an academic exercise, and you don't really need to use the DS extension anytime soon. PHP is pragmatic so is its array.