Add new flag ARRAY_FILTER_PACK_RESULT#22155
Conversation
|
Requested by someone at PHPTek and seemed pretty simple to implement
This would eliminate the need for an extra method call and improve performance Plenty of existing code would use this: https://github.com/search?q=language%3Aphp%20-is%3Afork%20-is%3Aarchived%20%2F%5C%5C%3Farray_values%5C(%5Cs*%5C%5C%3Farray_filter%2F&type=code let me know if an RFC is needed, not sure if this is small enough or not |
|
Excuse my ignorance. Isn't technicly Wouldn't |
|
I was working on this topic in the past, and there are already some opinions about the proper direction. #18291 It would require discussion on the internals about the clear and consistent direction. I would be happy for the |
A packed array is one with consecutive integer indexes, basically an array that would pass https://www.php.net/manual/en/function.array-is-list.php - see Lines 1612 to 1615 in 9898293 @iluuu1994 @TimWolla you participated in the discussion on #18291 - thoughts on adding this as a new flag? |
This proves my point. A packed array can have holes, therefore using that name here is wrong and confusing. Also, if you search php documentation sources for "packed array" you'll find almost nothing. So, people don't know what a "packed array" really is. If there's a vote I'd vote yes for this, but not with the proposed const name. |
|
The standard terminology is "preserve keys". You'd need the inverse, so maybe "discard keys". Ergonomically, I'm not sure this is much better than But I don't have any strong feelings on adding the flag itself. |
No description provided.