note 96533 deleted from function.array-search by levim

From: Date: Mon, 24 Feb 2014 22:44:46 +0000
Subject: note 96533 deleted from function.array-search by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198699@lists.php.net to get a copy of this message
Note Submitter: camden dot michael at gmail dot com ---- 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 (#198699) next »