note 7095 deleted from function.in-array by jimw

From: Date: Fri, 07 Dec 2001 21:06:02 +0000
Subject: note 7095 deleted from function.in-array by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-21958@lists.php.net to get a copy of this message
For those of you who are still using PHP 3 and those who want in_array to return the key for the value being searched for, try the following alternative function: function is_in_array($needle,$haystack) { $needleFound = false; $returnValue = false; reset($haystack); while ((list($key,$value) = each($haystack)) && !$needleFound) { if ($needle == $value) { $needleFound = true; $returnValue = $key; } } return $returnValue; }

« previous php.notes (#21958) next »