#37190 [Opn->Bgs]: non-local associative arrays are inaccessible
| From: | mike@php.net | Date: | Tue, 25 Apr 2006 06:53:41 +0000 |
| Subject: | #37190 [Opn->Bgs]: non-local associative arrays are inaccessible | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-96190@lists.php.net to get a copy of this message | ||
ID: 37190
Updated by: mike@php.net
Reported By: mlandis at pnmx dot com
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Fedora Core 4
PHP Version: 5.1.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2006-04-25 05:02:34] mlandis at pnmx dot com
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 this bug report at http://bugs.php.net/?id=37190&edit=1