#37190 [NEW]: non-local associative arrays are inaccessible

From: Date: Tue, 25 Apr 2006 05:02:34 +0000
Subject: #37190 [NEW]: non-local associative arrays are inaccessible
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-96189@lists.php.net to get a copy of this message
From: mlandis at pnmx dot com Operating system: Fedora Core 4 PHP version: 5.1.2 PHP Bug Type: Arrays related Bug description: non-local associative arrays are inaccessible Description: ------------ Associative array reference, e.g. $monIdx = $sti["Mar"]; behaves as expected if array $sti has local scope, but if the line of code above appears within a function and $sti is declared outside the function, you get nothing . Reproduce code: --------------- $sti = array( "Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12 ); function foobar( $monSt ) { return $sti[$monSt]; } $res = foobar( "May" ); echo "res=$res<br>\r\n"; Expected result: ---------------- res=5<br>\r\n Actual result: -------------- res=<br>\r\n -- Edit bug report at http://bugs.php.net/?id=37190&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37190&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=37190&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37190&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37190&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37190&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37190&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37190&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37190&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37190&r=support Expected behavior: http://bugs.php.net/fix.php?id=37190&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37190&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37190&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37190&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37190&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37190&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37190&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37190&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37190&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37190&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37190&r=mysqlcfg

« previous php.bugs (#96189) next »