From: dsysko at gmail dot com
Operating system: Ubuntu 9.10: 2.6.28-16 x64
PHP version: 5.3.1
PHP Bug Type: Scripting Engine problem
Bug description: case in_array does not recognize array var
Description:
------------
A pre-defined array passed to in_array() within switch{case( interpreted
as NULL for both flat and multi-dimensional arrays.
php config:
Configure Command => './configure' '--with-openssl' '--with-pgsql'
'--with-tidy' '--with-zlib' '--with-curl' '--with-apxs2=/usr/sbin/apxs'
'--with-gd' '--with-png-dir=/usr' '--with-jpeg-dir=/usr'
'--with-freetype-dir=/usr' '--with-zlib-dir=/usr'
Reproduce code:
---------------
$arrChoices = array('numberfood' => array('apple','pie',5) , 'monkeys' =>
array('frank','chimpanzee'));
function notArraysWhat ($i) {
switch ($i) {
case (in_array($i , $arrChoices['numberfood'])):
echo "$i is either a number or a food.\n";
break;
case (in_array($i , $arrChoices['monkeys'])):
echo "$i is a monkey, or smells like one.\n";
break;
}
}
notArraysWhat('pie');
Expected result:
----------------
STDOUT: pie is either a number or a food.
Actual result:
--------------
STDOUT: Warning: in_array() expects parameter 2 to be array, null given in
/export/servers/ETG/ContentCollection/cc/testing.php on line
--
Edit bug report at http://bugs.php.net/?id=50307&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50307&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50307&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50307&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50307&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=50307&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50307&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=50307&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=50307&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=50307&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=50307&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=50307&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=50307&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=50307&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50307&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50307&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50307&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=50307&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=50307&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=50307&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=50307&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=50307&r=mysqlcfg