Re: Proposal: Adding an ARRAY_FILTER_REINDEX flag to array_values
| From: | Guilliam Xavier | Date: | Mon, 20 Sep 2021 11:54:12 +0000 |
| Subject: | Re: Proposal: Adding an ARRAY_FILTER_REINDEX flag to array_values | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116107@lists.php.net to get a copy of this message | ||
On Sun, Sep 19, 2021 at 3:11 PM tyson andre <tysonandre775@hotmail.com>
wrote:
> Hi internals,
>
> Currently, array_filter will always return the original keys.
> This often requires an additional wrapping call of
> array_values(array_filter(...)) to reindex the keys and return a list.
> (or applications may not realize there will be gaps in the keys until it
> causes a bug or unexpected JSON encoding, etc.)
>
Hi,
This "issue" is not limited to array_filter(), there's also array_unique()
and even array_diff()/array_intersect() whose variadic signature doesn't
allow to add a flag (I think?)...
PS: and array_column() has the opposite issue...
--
Guilliam Xavier