#40509 [Asn->Csd]: key() function changed behaviour if global array is used within function

From: Date: Tue, 24 Jul 2007 19:26:50 +0000
Subject: #40509 [Asn->Csd]: key() function changed behaviour if global array is used within function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115397@lists.php.net to get a copy of this message
ID: 40509 Updated by: dmitry@php.net Reported By: alex dot killing at gmx dot de -Status: Assigned +Status: Closed Bug Type: Arrays related Operating System: MaxOsX/RedHat PHP Version: 5.2.1 Assigned To: dmitry New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2007-07-14 10:13:46] jani@php.net See also bug #41372 ------------------------------------------------------------------------ [2007-03-19 19:59:03] ashnazg@php.net Tested this example against the 5.2.1 zipfile from php.net on WinXP and the problem does occur. Also tested it against the 5.2 snapshot (php5.2-win32-200703191630.zip) from php.net, on WinXP, and the problem seems to still exist. ------------------------------------------------------------------------ [2007-03-06 13:19:33] dmitry@php.net see also http://bugs.php.net/bug.php?id=40705 ------------------------------------------------------------------------ [2007-02-16 15:24:36] alex dot killing at gmx dot de Description: ------------ If a global array is assigned to a local variable as in the example, and the local variable is iterated afterwards, the key() function changed the behaviour in the global scope with PHP 5.2.1. Reproduce code: --------------- <?php function foo() { global $arr; $c = $arr["v"]; foreach ($c as $v) {} } $arr["v"] = array("a"); echo "-".key($arr["v"])."-"; // prints "0" foo(); echo "<br/>-".key($arr["v"])."-"; // prints "" since 5.2.1 ("0" on all prior versions) ?> Expected result: ---------------- -0- -0- Actual result: -------------- -0- -- ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40509&edit=1

« previous php.bugs (#115397) next »