Re: [RFC][Under Discussion] Add functions array_key_first()and array_key_last()
| From: | Nicolas Grekas | Date: | Wed, 20 Jun 2018 14:06:46 +0000 |
| Subject: | Re: [RFC][Under Discussion] Add functions array_key_first()and array_key_last() | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102322@lists.php.net to get a copy of this message | ||
> if ([$key, $value] = array_last($input) {
>
+1 for this proposal, I would even go one step further and suggest a single
function, with an index as second argument:
if ([$key, $value] = array_index($input, $index) {
when 0 === $index => returns the first, -1 === $index returns the last,
etc.