Re: [DRAFT] RFC - array_column() function
| From: | Larry Garfield | Date: | Sat, 23 Jun 2012 05:15:40 +0000 |
| Subject: | Re: [DRAFT] RFC - array_column() function | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60944@lists.php.net to get a copy of this message | ||
On 06/22/2012 04:20 PM, Scott MacVicar wrote:
Hey Ben, On 22 Jun 2012, at 08:52, Ben Ramsey wrote:+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 GarfieldOn 6/22/12 5:32 AM, Léo Peltier wrote: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 - SHi, 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.