note 45539 deleted from function.in-array by danbrown

From: Date: Mon, 08 Jun 2009 21:46:06 +0000
Subject: note 45539 deleted from function.in-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-156522@lists.php.net to get a copy of this message
Note Submitter: lordfarquaad at notredomaine dot net ---- This function will be faster, as it doesn't compare all elements, it stops when it founds the good one. It also works if $haystack is not an array :-) <?php function in_array_multi($needle, $haystack) { if(!is_array($haystack)) return $needle == $haystack; foreach($haystack as $value) if(in_array_multi($needle, $value)) return true; return false; } ?>

« previous php.notes (#156522) next »