|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-04-25 06:53 UTC] mike@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 08:00:01 2025 UTC |
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