note 92838 added to function.in-array
| From: | steakpinball+php at gmail dot com | Date: | Tue, 11 Aug 2009 12:02:05 +0000 |
| Subject: | note 92838 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159316@lists.php.net to get a copy of this message | ||
The function which Robin is proposing is known as an Iterative (as opposed to Recursive) Binary
Search. It is indeed faster, but can only be used in situations when the haystack is in ascending
order. If the haystack is not sorted it may return incorrect results. For this reason it cannot
always be used as a direct replacement for in_array. For general purpose arrays, in_array is as good
as it gets.
----
Server IP: 69.147.83.197
Probable Submitter: 72.77.26.129
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/92838
Del: integrated -- https://master.php.net/note/delete/92838/integrated
Del: useless -- https://master.php.net/note/delete/92838/useless
Del: bad code -- https://master.php.net/note/delete/92838/bad+code
Del: spam -- https://master.php.net/note/delete/92838/spam
Del: non-english -- https://master.php.net/note/delete/92838/non-english
Del: in docs -- https://master.php.net/note/delete/92838/in+docs
Del: other reasons-- https://master.php.net/note/delete/92838
Reject -- https://master.php.net/note/reject/92838
Search -- https://master.php.net/manage/user-notes.php