|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-02-11 05:53 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 08:00:01 2025 UTC |
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"; } ?>