note 71400 added to function.in-array
| From: | lafo at osu1 dot php dot net | Date: | Mon, 27 Nov 2006 04:36:35 +0000 |
| Subject: | note 71400 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120097@lists.php.net to get a copy of this message | ||
The specification of this function is misleading.
<?php
$os = array("mac"=>"Mac", "NT", "Irix",
"Linux");
if (in_array("mac", $os)) {
echo "Got mac";
}
// prints Got mac !!!
?>
in_array searches both values AND indexes IF it is not running in the strict mode!
Correct specification: Checks if a value or a key exists in an array. In the strict mode, checks if
a value exists in an array.
----
Server IP: 216.194.113.175
Probable Submitter: 68.195.88.78
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/71400
Del: integrated -- https://master.php.net/note/delete/71400/integrated
Del: useless -- https://master.php.net/note/delete/71400/useless
Del: bad code -- https://master.php.net/note/delete/71400/bad+code
Del: spam -- https://master.php.net/note/delete/71400/spam
Del: non-english -- https://master.php.net/note/delete/71400/non-english
Del: in docs -- https://master.php.net/note/delete/71400/in+docs
Del: other reasons-- https://master.php.net/note/delete/71400
Reject -- https://master.php.net/note/reject/71400
Search -- https://master.php.net/manage/user-notes.php