Re: Re: [PHP-DEV] [DRAFT] RFC - array_column() function
| From: | Morgan L. Owens | Date: | Mon, 25 Jun 2012 14:41:06 +0000 |
| Subject: | Re: Re: [PHP-DEV] [DRAFT] RFC - array_column() function | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60960@lists.php.net to get a copy of this message | ||
On 2012-06-25 04:19, Ralph Schindler wrote:
What we're discussing here is basically a dual to that: return all values indexed by a given key.[*] If the duality is continued, then what we get is array_values(array $input[, mixed $key]) (A third $strict argument would probably do more harm than good: the key can only be an integer or a non-numeric string, and using the same type coercion rules would smooth out differences in the $key argument.) [*] Yes, I know the symmetry isn't perfect, and why; the question is whether the difference is more likely to result in "Well, duh!" or "WTF?!".The term 'column' makes a lot of sense for PDO working with database columns, but there is no concept of a 'column' in the array structure or PHP as a whole, outside of database related functions.In the case of this addition, I do indeed like array_pluck as well, as column feel like an overloaded term. While casting around for other array_* names, I remembered that array_keys() can take a second (and third) argument. With it, the function returns all keys indexing a given value.