#31114 [Opn->Bgs]: foreach modify array

From: Date: Thu, 16 Dec 2004 10:41:55 +0000
Subject: #31114 [Opn->Bgs]: foreach modify array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-70329@lists.php.net to get a copy of this message
ID: 31114 Updated by: derick@php.net Reported By: clemens at gutweiler dot net -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux 2.4.27 PHP Version: 4.3.10 New Comment: I don't think this was ever supposed to work. Previous Comments: ------------------------------------------------------------------------ [2004-12-16 11:14:47] mc at tyumen dot ru Cangelog: "Backported Marcus' foreach() speedup patch from PHP 5.x." How I can remove this patch ? For example doesn't work Smarty. ------------------------------------------------------------------------ [2004-12-16 10:44:05] clemens at gutweiler dot net Description: ------------ foreach modifies an array, if key and value are the same variable. see reproduction code. Reproduce code: --------------- <?php $foo = array( 'foo' => 'bar', 'dings' => 'dongs' ); foreach( $foo as $k => $k ) {} var_dump( $foo ); ?> array(2) { ["foo"]=> string(5) "dings" ["dings"]=> NULL } Expected result: ---------------- array(2) { ["foo"]=> string(3) "bar" ["dings"]=> string(5) "dongs" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31114&edit=1

« previous php.bugs (#70329) next »