Re: [RFC] Add is_list(mixed $value): bool to check for list-like arrays
| From: | Mike Schinkel | Date: | Tue, 22 Dec 2020 21:26:43 +0000 |
| Subject: | Re: [RFC] Add is_list(mixed $value): bool to check for list-like arrays | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112604@lists.php.net to get a copy of this message | ||
> On Dec 22, 2020, at 8:22 AM, Josh Bruce <josh@joshbruce.dev> wrote:
>
>
>> For example, with
>>
>> $a = ['foo', 'bar', 'baz’];
>>
>>
is_list() will return true,
>> but if you run $a through asort(),
>> is_list() will return false
>> because the keys are no longer
>> consecutive integers, but is there any doubt this is still a list?
>> Maybe in a pure sense, it’s not, but I think this could be confusing.
>>
>
> tl;dr: Could add flags to is_array.
Please, no.
PHP needs fewer flags, not more.
-Mike