note 117837 added to function.array-search
| From: | maciej at speccode dot com | Date: | Tue, 18 Aug 2015 05:58:58 +0000 |
| Subject: | note 117837 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203371@lists.php.net to get a copy of this message | ||
FYI, remember that strict mode is something that might save you hours.
If you're searching for a string and you have a "true" boolean on the way - you will
get it as result (first occurrence). Example below:
<?php
$arr = [
'foo' => 'bar',
'abc' => 'def',
'bool' => true,
'target' => 'xyz'
];
var_dump( array_search( 'xyz', $arr ) ); //bool
var_dump( array_search( 'xyz', $arr, true ) ); //target
?>
----
Server IP: 72.52.91.14
Probable Submitter: 2a01:112f:695:1100:ac5a:9a61:1b40:76fb
----
Manual Page -- http://php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/117837
Del: integrated -- https://master.php.net/note/delete/117837/integrated
Del: useless -- https://master.php.net/note/delete/117837/useless
Del: bad code -- https://master.php.net/note/delete/117837/bad+code
Del: spam -- https://master.php.net/note/delete/117837/spam
Del: non-english -- https://master.php.net/note/delete/117837/non-english
Del: in docs -- https://master.php.net/note/delete/117837/in+docs
Del: other reasons-- https://master.php.net/note/delete/117837
Reject -- https://master.php.net/note/reject/117837
Search -- https://master.php.net/manage/user-notes.php