note 50752 deleted from function.in-array by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:55:28 +0000 |
| Subject: | note 50752 deleted from function.in-array by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134481@lists.php.net to get a copy of this message | ||
Note Submitter:
----
I'd have to disagree with the previous poster. The behavior is not "completely as
expected." If I do not know what data is in an array, and I search for the value
"123abc", I certainly don't expect it to match the integer 123. I expect it to match
the string "123abc," period. The needle should not be converted for the sake of
comparison! In the case of a string in the haystack or needle, the other value should be converted
to a string before comparison. This guarantees only equivalent values will be matched.
This kind of behavior is the reason I always use === in PHP instead of ==. Too many things match
otherwise. Luckily, the "strict" option here gives the right results.
-Dan