note 21845 modified in function.array-search by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:49:19 +0000 |
| Subject: | note 21845 modified in function.array-search by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79907@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:
<?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.
--was--
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://php.net/manual/en/function.array-search.php