note 93614 deleted from language.operators.comparison by cmb
| From: | cmb@php.net | Date: | Sun, 11 Aug 2019 11:43:36 +0000 |
| Subject: | note 93614 deleted from language.operators.comparison by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211845@lists.php.net to get a copy of this message | ||
Note Submitter: pinkgothic at gmail dot com
----
"Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then
arrays are uncomparable, otherwise - compare value by value (see following example)."
The example covers this behaviour, but it isn't immediately obvious, so:
If you're doing loose comparisons in PHP, note that they differ from checking each value
individually like $value1==$value2 by adding what amounts to an empty($value1)==empty($value2) check
into the mix. I found this out by investigating some (to me) bizarre behaviour.
[Note that the example contains no ==, just > and <. It's its absence that perceivedly
'causes empty() to fire'.]
I was also pleasantly surprised to see PHP recurse. Also clear if you keep in mind that the example
implies another function call to itself with > and < if both operands are arrays, but IMO
definitely worth stating.
It might also be worth noting that the order of array keys doesn't matter, even if a foreach()
would see a 'different' array. Again, covered by the example, but might be worth
stressing.