Re: [RFC] [Discussion] array_get and array_has functions
| From: | Barel | Date: | Sun, 05 Apr 2026 09:07:05 +0000 |
| Subject: | Re: [RFC] [Discussion] array_get and array_has functions | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130568@lists.php.net to get a copy of this message | ||
On Sat, 4 Apr 2026 at 18:54, Alexandru Pătrănescu <drealecs@gmail..com>
wrote:
> Hi Carlos,
>
> This sounds interesting.
>
> A mature solution used in JS is lodash, with the get and has functions:
> - https://lodash.com/docs/#get
> - https://lodash.com/docs/#has
> Also, from what I could search, Laravel array helpers have this
> functionality as well:
> - https://laravel.com/docs/master/helpers#method-array-get
> - https://laravel.com/docs/master/helpers#method-array-has
> I was curious; did you research both, and maybe also other libraries? If
> yes, it would be nice to mention this in the RFC.
>
> They have some options, like allowing the key parameter as a list of
> strings as well.
> And also escaping the dot in the key in one way or another.
>
> --
> Alex
>
Hi Alex,
Thanks for your comments. I have updated the RFC with references to the
Laravel and Lodash implementations
Allowing the key parameter as a list of strings sounds really interesting,
let me explore that possibility
Several other people mentioned escaping dots as something important, so I
will look into adding that to the implementation
Cheers
Carlos
>
>
> On Sat, Apr 4, 2026 at 5:08 PM Barel <barel.barelon@gmail.com> wrote:
>
>> Hi,
>>
>> I would like to open the discussion on my proposal to add two small,
>> focused array functions for retrieving and checking nested array elements
>> using dot notation.
>>
>> This is the link to the RFC:
>> https://wiki.php.net/rfc/array_get_and_array_has
>>
>> This is the link to the proposed implementation:
>> https://github.com/php/php-src/pull/21637
>>
>> Thanks!!
>>
>> Carlos
>>
>