note 20822 modified in function.array-search by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:49:22 +0000 |
| Subject: | note 20822 modified in function.array-search by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79810@lists.php.net to get a copy of this message | ||
To future proof against the 4.2.0 return change something like this should work:
<?php
$key = array_search($needle, $haystack);
if(is_null($key))
$retval = false;
?>
and then test using:
<?php
if($key !== false)
{
// $key exists in $haystack.
}
?>
--was--
To future proof against the 4.2.0 return change something like this should work:
$key = array_search($needle, $haystack);
if(is_null($key))
$retval = false;
and then test using:
if($key !== false)
{
// $key exists in $haystack.
}
http://php.net/manual/en/function.array-search.php