note 96553 rejected from function.array-search by danbrown

From: Date: Thu, 04 Mar 2010 17:58:46 +0000
Subject: note 96553 rejected from function.array-search by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166669@lists.php.net to get a copy of this message
Note Submitter: camden dot michael at gmail dot com ---- Whoops, meant to use strcasecmp... I needed a case insensitive array search function for a project... <?php /** * Performs the same function as array_search except that it is case * insensitive * @param mixed $needle * @param array $haystack * @return mixed */ function array_nsearch($needle, array $haystack) { $it = new IteratorIterator(new ArrayIterator($haystack)); foreach($it as $key => $val) { if(strcasecmp($val,$needle) === 0) { return $key; } } return false; } ?>

« previous php.notes (#166669) next »