note 74635 added to language.operators.array
| From: | Q1712 at online dot ms | Date: | Sat, 21 Apr 2007 00:54:27 +0000 |
| Subject: | note 74635 added to language.operators.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125724@lists.php.net to get a copy of this message | ||
The example may get u into thinking that the identical operator returns true because the key of
apple is a string but that is not the case, cause if a string array key is the standart
representation of a integer it's gets a numeral key automaticly.
The identical operator just requires that the keys are in the same order in both arrays:
<?php
$a = array (0 => "apple", 1 => "banana");
$b = array (1 => "banana", 0 => "apple");
var_dump($a === $b); // prints bool(false) as well
$b = array ("0" => "apple", "1" => "banana");
var_dump($a === $b); // prints bool(true)
?>
----
Server IP: 69.147.83.197
Probable Submitter: 84.158.116.149
----
Manual Page -- http://www.php.net/manual/en/language.operators.array.php
Edit -- https://master.php.net/note/edit/74635
Del: integrated -- https://master.php.net/note/delete/74635/integrated
Del: useless -- https://master.php.net/note/delete/74635/useless
Del: bad code -- https://master.php.net/note/delete/74635/bad+code
Del: spam -- https://master.php.net/note/delete/74635/spam
Del: non-english -- https://master.php.net/note/delete/74635/non-english
Del: in docs -- https://master.php.net/note/delete/74635/in+docs
Del: other reasons-- https://master.php.net/note/delete/74635
Reject -- https://master.php.net/note/reject/74635
Search -- https://master.php.net/manage/user-notes.php