#31927 [Opn->Bgs]: in_array() not working with array containing strings as needle

From: Date: Fri, 11 Feb 2005 19:52:15 +0000
Subject: #31927 [Opn->Bgs]: in_array() not working with array containing strings as needle
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73895@lists.php.net to get a copy of this message
ID: 31927 Updated by: tony2001@php.net 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

« previous php.bugs (#73895) next »