note 12045 deleted from function.array-search by jimw

From: Date: Thu, 25 Oct 2001 23:14:32 +0000
Subject: note 12045 deleted from function.array-search by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-19444@lists.php.net to get a copy of this message
Note that in the above example you cannot tell the difference between "not found" and "element 0 found" which means that you have to check this beforehand with the in_array function. If you have a PHP4 which doesn't have this function, try defining it yourself with this function: function array_search ($needle, $haystack, $strict = FALSE) { for ($int = 0; $int < count($haystack); ++$int) { if ($strict) { if ($haystack[$int] === $needle) return $int; } else { if ($haystack[$int] == $needle) return $int; } } return FALSE; }

« previous php.notes (#19444) next »