On Sat, Jul 14, 2012 at 3:04 AM, Anthony Ferrara <ircmax...@gmail.com> wrote:
> Stas,
>
>> I like this idea. array_first_key would be nice too
>>
>> I am probably missing something, but what those would allow to do that
>> rewind/end+key() doesn't do?
>>
>
> The big thing that it does that end()+key() doesn't do is really what it
> doesn't do (update the internal pointer).
>
> end() modifies the array pointer. So if you try this in user-land:
>
> function array_last_key(array $array) {
>     end($array);
>     return key($array);
> }
>
> It will always force a full copy of the array (at least the hash table).
> Implementing this as a core function however would eliminate that one
> side-effect...

and it beats doing $var = null; if(isset($array[0])) { $var = $array[0]; }

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to