Add functions array_key_first() and array_key_last()

php.internals

Enno Woortmann

8 years ago
Hello Internals, I'd like to ask for feedback for my idea. Some years ago a pull request came up to add array_key_first(), array_key_last(), and array_key_index() functions (#347 <https://github.com/php/php-src/pull/347>). In the meantime a RFC was published to integrate the functions (https://wiki.php.net/rfc/array_key_first_last_index) which was discussed in the mailing list two and a half years ago (https://externals.io/message/89955). Since the pull request and the RFC doesn't sustain a real progress and in my opinion at least the functions array_key_first(array $a) and array_key_last(array $a) would be handy in some cases I'd like to propose using a smaller functional scope as a first step including only this two functions. Additional features like returning the value of the requested element or the function array_key_index() could be implemented in a later stage if required. I implemented those two functions in a different implementation approach which tries to use as much existing code as possible available and already created a pull request at https://github.com/php/php-src/pull/3256. For the next steps I'd like to create a new RFC as the functional scope differs to the existing RFC. Therefor I request a PHP.net wiki account (wiki username: wol-soft) to create a new RFC. Regards, Enno --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus

Christoph Becker

8 years ago
Hi Enno! On 11.06.2018 at 14:15, Enno Woortmann wrote:
> For the next steps I'd like to create a new RFC as the functional scope > differs to the existing RFC. Therefor I request a PHP.net wiki account > (wiki username: wol-soft) to create a new RFC.
You should have RFC karma now.
-- Christoph M. Becker

Enno Woortmann

8 years ago
Hi Christoph, On 11.06.2018 at 15:21, Christoph M. Becker wrote:
> You should have RFC karma now. >
Thanks for the RFC karma, everything worked fine. I've created a new RFC for this topic located at https://wiki.php.net/rfc/array_key_first_last Thanks, Enno --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus

Côme Chilliet

8 years ago
Hello, Shouldn’t we also add array_first and array_last for consistency? reset and end may be used for this but they modify the array state and cannot be called on function results. Côme

Gabriel Caruso

8 years ago
Em ter, 12 de jun de 2018 às 07:04, Côme Chilliet <come@opensides.be> escreveu:
> Hello, > > Shouldn’t we also add array_first and array_last for consistency? > reset and end may be used for this but they modify the array state and > cannot be called on function results. > > Côme > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
Hi Côme, Thanks for bringing the discussion about `array_first` and `array_last`. I'm pretending to code it and propose those in the next version of PHP after PHP 7.3, with the names `array_find_first` and `array_find_last` :) Thanks,
-- Gabriel Caruso