I stumbled over a few articles (e.g. this one) and infos that suggest PHP's in_array()
goes through the whole array.
Now there is a possible duplicate of this question here: How does PHP's in_array function work? but the OP was obviously satisfied with the copy/paste of the C language function definition and no further description...
My question however is:
Does PHP's in_array()
really go through the whole array?
I tried to look further and go after the ZEND_HASH_FOREACH_KEY_VAL
, but then it got a bit confusing:
- the C-language definition of
php_search_array()
... AKAin_arary()
in PHP - Codes of
ZEND_HASH_FOREACH_KEY_VAL
andZEND_HASH_FOREAC
Only thing I am sure of is that since the ??iteration?? happens on the "C-level" it should be faster than "manual" foreach
...