note 50704 added to function.in-array

From: Date: Mon, 07 Mar 2005 22:02:25 +0000
Subject: note 50704 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-86068@lists.php.net to get a copy of this message
I hope everyone sees that the previous poster's comments are incorrect, in that the behavior is not ridiculous but completely as expected. > in_array('123abc', array(123)) returns true A string is being compared to an integer, in such a situation PHP assumes an integer context wherein '123abc' evaluates to the integer 123, thus a match. > in_array('123abc', array('123')) returns false A string is being compared to a string and OBVIOUSLY these strings are not equal. ---- Manual Page -- http://www.php.net/manual/en/function.in-array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50704 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50704&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50704&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50704&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50704&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50704&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50704&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86068) next »