note 89414 deleted from function.array-search by levim
| From: | levim@php.net | Date: | Mon, 24 Feb 2014 22:43:21 +0000 |
| Subject: | note 89414 deleted from function.array-search by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198691@lists.php.net to get a copy of this message | ||
Note Submitter: greenmr
----
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;
}
?>