note 21845 added to function.array-search

From: Date: Wed, 29 May 2002 08:44:36 +0000
Subject: note 21845 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-31139@lists.php.net to get a copy of this message
For versions later than 4.2.0, the check isset($key) won't work properly because the function now returns false, which "isset". This change is missing in the Change Log! So the right way to use the function is: $key = array_search($needle, $array); if ($key!==null&&$key!==false) { ... } This example will work in both older and newer to 4.2.0 versions. P.S.: My previous post where isset() is used won't work in newer versions. -- http://www.php.net/manual/en/function.array-search.php http://master.php.net/manage/user-notes.php?action=edit+21845 http://master.php.net/manage/user-notes.php?action=delete+21845 http://master.php.net/manage/user-notes.php?action=reject+21845

« previous php.notes (#31139) next »