in_array algorithm
| From: | John Fulton | Date: | Wed, 06 Feb 2002 16:26:56 +0000 |
| Subject: | in_array algorithm | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-83719@lists.php.net to get a copy of this message | ||
Does anyone know which algorithm in_array() uses?
For example, if I say
in_array("foo", $arr)
Does in_array() do an unordered sequential serach of $arr for
"foo" which takes up to n comparisons [where n = count($arr)],
or does it do a binary search which takes about lg(n) comparisons?
Is it up to me to maintain a sorted array in the later case?
Thanks,
John