ID: 30036
User updated by: marek at lewczuk dot com
Reported By: marek at lewczuk dot com
Status: Bogus
Bug Type: Arrays related
Operating System: Windows
PHP Version: 4.3.8
New Comment:
Right, it works with 3rd parameter, but it is not the point - is string
"test" equal to boolean "true" ? Even if we are not comparing variable
types, then "test" is not equal to "1". For example, I have an array
with strings, integers, boolean - I'm looking for any "123" value - I
don't care if this is an integer or string - the value is important. In
this case, I can't use in_array with 3rd parameter, because it will not
find all all correct values.
examples:
in_array('232', array(232, '232', true))
this will return true - correct
in_array('232', array(232, true), true)
this will return false - correct
in_array('232', array(233, '233', true))
this will return true - wrong
In my opinion this is not correct behavior...
Previous Comments:
------------------------------------------------------------------------
[2004-09-15 10:56:57] [EMAIL PROTECTED]
Use the 3rd optional parameter (for strict search) which makes
in_array() to check the type too. NOT a bug.
------------------------------------------------------------------------
[2004-09-09 10:04:27] marek at lewczuk dot com
Description:
------------
When you have an array with boolean values, then in_array will always
return true.
Reproduce code:
---------------
print in_array("test it", array(true, true, "sdsd" => true))
Expected result:
----------------
should return false
Actual result:
--------------
true
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30036&edit=1