note 89414 added to function.array-search
| From: | greenmr at osu1 dot php dot net | Date: | Fri, 06 Mar 2009 19:02:11 +0000 |
| Subject: | note 89414 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-151569@lists.php.net to get a copy of this message | ||
Incidentally, the KeyCompare() function I described above is a generalized version. Since
array_bsearch() doesn't care about specific return values, just greater then, less than, or
equal to zero, when you are comparing two numbers you can greatly simplify the comparison function
to something like:
<?php
function KeyCompare( $obj, $needle ) {
return $obj['my_key'] - $needle;
}
?>
----
Server IP: 216.235.13.26
Probable Submitter: 69.196.166.240
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/89414
Del: integrated -- https://master.php.net/note/delete/89414/integrated
Del: useless -- https://master.php.net/note/delete/89414/useless
Del: bad code -- https://master.php.net/note/delete/89414/bad+code
Del: spam -- https://master.php.net/note/delete/89414/spam
Del: non-english -- https://master.php.net/note/delete/89414/non-english
Del: in docs -- https://master.php.net/note/delete/89414/in+docs
Del: other reasons-- https://master.php.net/note/delete/89414
Reject -- https://master.php.net/note/reject/89414
Search -- https://master.php.net/manage/user-notes.php