# Add functions array_key_first() and array_key_last()

- Thread: https://externals.io/message/102225
- Original archive: https://news-web.php.net/php.internals/102225
- Started by Enno Woortmann on 2018-06-11T12:15:33+00:00
- Messages: 5
- RFC: Add array_key_(first|last|index) functions (Obsolete) — https://externals.io/rfc/array_key_first_last_index.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #102225 — Enno Woortmann — 2018-06-11T12:15:33+00:00

URL: https://externals.io/message/102225#102225

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

---

## #102227 — Christoph M. Becker — 2018-06-11T13:21:35+00:00

URL: https://externals.io/message/102225#102227 · In reply to: #102225

Hi Enno!



> 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

---

## #102230 — Enno Woortmann — 2018-06-11T15:05:29+00:00

URL: https://externals.io/message/102225#102230 · In reply to: #102227

Hi Christoph,



> 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

---

## #102232 — come@opensides.be — 2018-06-12T10:03:54+00:00

URL: https://externals.io/message/102225#102232 · In reply to: #102230

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

---

## #102233 — Gabriel Caruso — 2018-06-12T10:54:34+00:00

URL: https://externals.io/message/102225#102233 · In reply to: #102232

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
>
> --
> 
> 
>
>
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
