Re: [RFC] [Discussion] array_first() and array_last()
| From: | Larry Garfield | Date: | Tue, 08 Apr 2025 20:48:32 +0000 |
| Subject: | Re: [RFC] [Discussion] array_first() and array_last() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127077@lists.php.net to get a copy of this message | ||
On Sat, Apr 5, 2025, at 10:51 AM, Niels Dossche wrote:
> Hi internals
>
> I'm opening the discussion for the RFC "array_first() and array_last()".
> https://wiki.php.net/rfc/array_first_last
>
> Kind regards
> Niels
To add another argument: the reset() workaround doesn't work with a readonly array property,
because it does modify the array's internal pointer.
https://3v4l.org/Zo5dZ
Yes, I have in fact run into this situation in real code, which led me to use the
$a[array_key_first($a)] dance instead. I'd love to replace it with a single call.
--Larry Garfield