note 116518 added to function.array-search
| From: | nan at designpromote dot co dot uk | Date: | Fri, 16 Jan 2015 16:45:25 +0000 |
| Subject: | note 116518 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201439@lists.php.net to get a copy of this message | ||
$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."
----
Server IP: 72.52.91.14
Probable Submitter: 92.29.4.233
----
Manual Page -- http://php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/116518
Del: integrated -- https://master.php.net/note/delete/116518/integrated
Del: useless -- https://master.php.net/note/delete/116518/useless
Del: bad code -- https://master.php.net/note/delete/116518/bad+code
Del: spam -- https://master.php.net/note/delete/116518/spam
Del: non-english -- https://master.php.net/note/delete/116518/non-english
Del: in docs -- https://master.php.net/note/delete/116518/in+docs
Del: other reasons-- https://master.php.net/note/delete/116518
Reject -- https://master.php.net/note/reject/116518
Search -- https://master.php.net/manage/user-notes.php