ID: 31927
Updated by: [EMAIL PROTECTED]
Reported By: bart at mediawave dot nl
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: WinXP
PHP Version: 5CVS-2005-02-11 (dev)
New Comment:
No bug here: in_array() looks for exact match.
This code works fine:
<?php
$a = array(array("NT", "Linux"), array("Irix", "Linux"), "OS2");
if (in_array(array("NT", "Linux"), $a)) {
echo "NT Linux found\n";
}
?>
Previous Comments:
------------------------------------------------------------------------
[2005-02-11 05:53:04] bart at mediawave dot nl
Description:
------------
in_array() doesn't work with an array containing strings (larger then
one character) as a needle.
Reproduce code:
---------------
<?php
$a = array(array("Mac", "NT"), array("Irix", "Linux"), "OS2");
if (in_array(array("NT", "Linux"), $a)) {
echo "NT Linux found\n";
}
if (in_array(array("XP", "Unix"), $a)) {
echo "XP Unix found\n";
}
if (in_array("OS2", $a)) {
echo "OS2 found\n";
}
?>
Expected result:
----------------
NT Linux found
OS2 found
Actual result:
--------------
OS2 found
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31927&edit=1