Sign in
Log inSign up
Geni Jaho

1.2K reads

3 comments

Lars Moelleken
Lars Moelleken
Apr 9, 2023

count($a) === 0 is even more readable, or? 🤔

1
·
·1 reply
Geni Jaho
Geni Jaho
Author
·Apr 9, 2023

I think yes, it's at the same level as empty($a), but the point is we're letting go of a tiny bit of readability in exchange for a more trusted/clear code. When we do $a === [] we know for sure that it's a plain array and not an Arrayable object or similar. It's down to personal preference anyway.

1
·
Erland Muchasaj
Erland Muchasaj
Apr 11, 2023

Geni Jaho array_key_exists() and isset() are not interchangeable, because they have different use cases.

Of course most of the time you can use array_key_exists instead of isset but in some cases, you can not.

See here for more details

1
·