#24396 [Opn]: foreach ($k=>$v), the key $k is missing

From: Date: Mon, 30 Jun 2003 10:48:30 +0000
Subject: #24396 [Opn]: foreach ($k=>$v), the key $k is missing
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-42830@lists.php.net to get a copy of this message
ID: 24396 Updated by: sniper@php.net Reported By: jlim at natsoft dot com Status: Open Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 5.0.0b1 (beta1) New Comment: 4.3.3RC2-dev Array ( [a] => 1 [b] => 2 [c] => 3 ) (a=>1) (b=>2) (c=>3) (just checked that this is just 5.0.0b1 issue) Previous Comments: ------------------------------------------------------------------------ [2003-06-29 23:48:26] jlim at natsoft dot com Description: ------------ The following script below fails (missing $k). Reproduce code: --------------- <?php error_reporting(E_ALL); echo PHP_VERSION."<br>"; print_r($_GET); foreach($_GET as $k=>$v) { global $$k; print " ($k=>$v) "; $$k = $v; } ?> Expected result: ---------------- 5.0.0b1 Array ( [a] => 1 [b] => 2 [c] => 3 ) (a=>1) (b=>2) (c=>3) Actual result: -------------- 5.0.0b1 Array ( [a] => 1 [b] => 2 [c] => 3 ) (=>1) (=>2) (=>3) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24396&edit=1

« previous php.bugs (#42830) next »