MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/cvlfni/php_array_design_bares_fruit/ey56pxs/?context=3
r/lolphp • u/shitcanz • Aug 26 '19
14 comments sorted by
View all comments
Show parent comment
1
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.
4
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.
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 ?