note 56040 added to language.operators.array
| From: | kitdotlesteratlycosdotcodotuk at osu1 dot php dot net | Date: | Sun, 21 Aug 2005 16:01:56 +0000 |
| Subject: | note 56040 added to language.operators.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93998@lists.php.net to get a copy of this message | ||
When comparing arrays that have (some or all) element-values that are themselves array, then in PHP5
it seems that == and === are applied recursively - that is
* two arrays satisfy == if they have the same keys, and the values at each key satisfy == for
whatever they happen to be (which might be arrays);
* two arrays satisfy === if they have the same keys, and the values at each key satisfy === for
whatever (etc.).
Which explains what happens if we compare two arrays of arrays of arrays of...
Likewise, the corresponding inversions for != <> and !==.
I've tested this to array-of-array-of-array, which seems fairly convincing. I've not tried
it in PHP4 or earlier.
----
Manual Page -- http://www.php.net/manual/en/language.operators.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56040
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56040&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56040&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56040&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56040&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56040&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56040&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56040&report=yes
Search -- http://master.php.net/manage/user-notes.php