Re: Re: array_last_key() function
| From: | Rasmus Lerdorf | Date: | Sat, 14 Jul 2012 17:29:08 +0000 |
| Subject: | Re: Re: array_last_key() function | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-61230@lists.php.net to get a copy of this message | ||
On 07/14/2012 10:13 AM, Anthony Ferrara wrote:
> Gustavo,
>
> Why is the last key special? Why not a function to get the first or the
>> penultimate key?
>>
>
> How would such a function look?
I think the function would look just like the function we have for doing
this.
key(array_slice($arr,-2));
And no, this has no side-effect of changing the array pointer in $arr,
of course.
And array_last_key() is identical to array_slice($arr,-1) is it not?
The only thing array_last_key() saves is a single function call to
key(). That doesn't seem worth it to me.
-Rasmus