note 116518 deleted from function.array-search by crell
| From: | crell@php.net | Date: | Thu, 31 Mar 2022 20:48:03 +0000 |
| Subject: | note 116518 deleted from function.array-search by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217966@lists.php.net to get a copy of this message | ||
Note Submitter: nan at designpromote dot co dot uk
----
$array = ['a', 'b', 'c'];
$key = array_search('a', $array); //$key = 0
if ($key)
{
//even a element is found in array, but if (0) means false
//...
}
//the correct way
if (false !== $key)
{
//....
}
It's what the document stated "may also return a non-Boolean value which evaluates to
FALSE."