Re: note 96553 added to function.array-search

From: Date: Thu, 04 Mar 2010 17:43:20 +0000
Subject: Re: note 96553 added to function.array-search
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166670@lists.php.net to get a copy of this message
Mike; Regarding your submission below, please ignore the rejection email you'll get from the system. I hit the wrong link when trying to edit and merge your code, and am fixing it now. The rejection message is in error. Thanks. On Thu, Mar 4, 2010 at 12:56, <camden.michael@gmail.com> wrote: > 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; > } > ?> > ---- > Server IP: 64.71.164.2 > Probable Submitter: 70.99.89.86 > ---- > Manual Page -- > http://www.php.net/manual/en/function.array-search.php > Edit        -- https://master.php.net/note/edit/96553 > Del: integrated  -- > https://master.php.net/note/delete/96553/integrated > Del: useless     -- > https://master.php.net/note/delete/96553/useless > Del: bad code    -- > https://master.php.net/note/delete/96553/bad+code > Del: spam        --  > äH3™�œÏÐ#�Ëhttps://master.php.net/note/delete/96553/spam > Del: non-english -- > https://master.php.net/note/delete/96553/non-english > Del: in docs     -- > https://master.php.net/note/delete/96553/in+docs > Del: other reasons-- https://master.php.net/note/delete/96553 > Reject      -- https://master.php.net/note/reject/96553 > Search      -- https://master.php.net/manage/user-notes.php > > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- </Daniel P. Brown> daniel.brown@parasane.net || danbrown@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Looking for hosting or dedicated servers? Ask me how we can fit your budget!

« previous php.notes (#166670) next »