Re: RFC [Discussion] array_column results grouping

From: Date: Mon, 06 Dec 2021 10:23:59 +0000
Subject: Re: RFC [Discussion] array_column results grouping
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-116575@lists.php.net to get a copy of this message
> 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 <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

« previous php.internals (#116575) next »