note 75374 deleted from function.array-search by danbrown
| From: | danbrown@php.net | Date: | Wed, 29 Apr 2009 12:57:57 +0000 |
| Subject: | note 75374 deleted from function.array-search by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153977@lists.php.net to get a copy of this message | ||
Note Submitter: ben at reload dot me dot uk
----
A refinement on chappy at citromail dot hu's case-insensitive search function...
<?php
function array_isearch($str,$array){
foreach ($array as $k=>$v) {
if (strtolower($v) == strtolower($str)) { return $v; };
};
return false;
}
?>
Shall return false on no match or return the first value that matches if one or more matches are
found (same functionality as the array_search() function). It is also more efficient as it stops
searching the array once a match is found.