On 06/22/2012 04:20 PM, Scott MacVicar wrote:
Hey Ben,
On 22 Jun 2012, at 08:52, Ben Ramsey wrote:
On 6/22/12 5:32 AM, Léo Peltier wrote:
Hi,
Shouldn't this be called 'array_pluck'?
This is the name people usually use when implementing it in PHP (see
"array_pluck(" vs "array_column(" in Google) or in other languages/libs
(see underscorejs, prototypejs and RoR).
I'm open to changing or aliasing the name to array_pluck(), if others are in
agreement.
We have a version of this at Facebook and its called array_pull() it has a
third parameter and supports pulling a new key value too. You can find a copy
of it in Phabricator. There is also mpull() which is for methods. I'd recommend
combining the two methods to be honest and doing a single function that
supports index names or a method.
https://github.com/facebook/libphutil/blob/master/src/utils/utils.php#L143
- S
+1 on this functionality from me. I've had to implement it in
user-space way too often. :-) For the name, I'd suggest doing a survey
of other languages that PHP folks are likely to have had experience in
and going with whatever seems most common/similar to what's proposed
here, rather than debating it directly. :-)
--Larry Garfield
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php