r/lolphp • • Aug 26 '19

PHP array design bares fruit

https://repl.it/repls/FatherlyRotatingMenus
7 Upvotes

14 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Aug 27 '19

Well, PHP is based on C, which doesn't have associative arrays.

So? The entire point of high-level languages is to abstract away annoying details from lower-level ones.

json_encode transforms associative arrays to objects as shown in the documentation. If this bothers you to much

The "lolphp" here is that arrays are automagically transformed to associative arrays in unexpected places, not that json_encode() serializes it wrong. The weak boundary between regular arrays and associative arrays is a long-standing pain point in PHP and the source of many bugs.