Re: RFC [Discussion] array_column results grouping
| From: | Hassan Ahmed | Date: | Mon, 06 Dec 2021 19:37:28 +0000 |
| Subject: | Re: RFC [Discussion] array_column results grouping | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116577@lists.php.net to get a copy of this message | ||
The named arguments are a great thing to set in mind, but I think that
we will go to complicate it with optional arguments.
there is a comment on the PR that asks for another option to preserve
the sub-array index to be the new array index. also with the comments
by
Hendra Gunawan in mind. adding a new optional argument will make
it harder to expand it in the future.
Hassan Ahmed
On Mon, Dec 6, 2021 at 12:24 PM Claude Pache <claude.pache@gmail.com> wrote:
>
>
>
> Le 6 déc. 2021 à 09:44, Hassan Ahmed <7snovic@gmail.com> a écrit :
>
> Hello Folks, Thanks a lot for your feedback, as already mentioned in
> the RFC and as mentioned by Rowan too a new function is an option. I
> think that mostly we will go with the new function option.
> I will try to edit the PR to add a new function, does there any
> suggestions/naming conventions for the new function? a colleague
> suggested being array_group_by and Hendra already suggested to
> be
> array_column_group which is good too.
>
> Regards,
> Hassan
>
>
>
> Now that we have named arguments, the issue of long and complicated list of arguments is
> considerably weaken, since you can write:
>
> array_column($foo, column_key: 'name', grouping: true);
>
> in lieu of:
>
> array_column($foo, null, 'name', true)
>
> Also, an alternative to a new function, is reusing the same function with an alternative
> signature, as it was done for setcookie:
>
> https://www.php.net/manual/fr/function.setcookie.php
>
> I have no opinion about which of the three approaches (new parameter, same function with
> alternative signature, new function) is better; I just mention the various alternatives.
>
> —Claude