|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-11-12 22:11 UTC] me at my dot house
Description:
------------
If the haystack contains the boolean true, in_array returns true!!
Check this (PHP 4.2.3-8 debian package) :
Reproduce code:
---------------
<?php
$r=array("fzsgsdgsd","reazrazr","rezarzearzae",true);
$ret=in_array("tsuser_id",$r);
print $ret;
}
?>
Expected result:
----------------
false
Actual result:
--------------
true
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 23:00:01 2025 UTC |
marcus@zaphod /usr/src/php5 $ php -r 'var_dump(in_array("x",array(1,2,3,false)));' bool(false) marcus@zaphod /usr/src/php5 $ php -r 'var_dump(in_array("x",array(1,2,3,true)));' bool(true)That's what Ilia was getting at. If the third parameter to in_array() is true, types are also checked a-la ===. As per your example... jay@monty jay $ php -r 'var_dump(in_array("x",array(1,2,3,true)));' bool(true) jay@monty jay $ php -r 'var_dump(in_array("x",array(1,2,3,true), true));' bool(false) J