note 21845 deleted from function.array-search by levim

From: Date: Mon, 24 Feb 2014 22:36:11 +0000
Subject: note 21845 deleted from function.array-search by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198639@lists.php.net to get a copy of this message
Note Submitter: dakota at dir dot bg ---- 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: <?php $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.

« previous php.notes (#198639) next »