From: clemens at gutweiler dot net
Operating system: Linux 2.4.27
PHP version: 4.3.10
PHP Bug Type: Arrays related
Bug description: foreach modify array
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 bug report at http://bugs.php.net/?id=31114&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31114&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31114&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31114&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31114&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31114&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31114&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31114&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31114&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31114&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31114&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31114&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31114&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31114&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31114&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31114&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31114&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31114&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31114&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31114&r=mysqlcfg