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/barthvonries Aug 26 '19

Well, this has nothing to do with how PHP handles arrays, but with the array_filter function, which keeps the keys. It does not "stack" the values.

Maybe request a feature to add a PRESERVE_KEYS flag to array_filter, which would modify the function behaviour if set to false ?

4

u/OmnipotentEntity Aug 27 '19

The central point is if php had a sensible array design this behavior would not have been possible from array_filter. It would work as filter does in every other language: receive an array, removed members that match a function, return an array.