ID: 31114
Updated by: [EMAIL PROTECTED]
Reported By: clemens at gutweiler dot net
Status: Assigned
Bug Type: Arrays related
Operating System: Linux 2.4.27
PHP Version: 4.3.10
Assigned To: derick
New Comment:
scoop, your problem is because you need to upgrade your Zend
extensions. Your example works fine for me.
Previous Comments:
------------------------------------------------------------------------
[2004-12-16 18:55:50] scoop at freshmeat dot net
There definitely is a problem for cases using the syntax
$array = array('foo','bar','baz');
foreach($array as $value)
{
var_dump($value);
}
.. in which case $value will be output as an array:
array(2) {
[0]=>
string(3) "foo"
[1]=>
int(0)
}
.. which obviously breaks a few code snippets.
------------------------------------------------------------------------
[2004-12-16 13:07:17] [EMAIL PROTECTED]
(The only bug here is that it doesn't give a warning, using $k for both
key and value is not supposed to work!)
------------------------------------------------------------------------
[2004-12-16 11:41:54] [EMAIL PROTECTED]
I don't think this was ever supposed to work.
------------------------------------------------------------------------
[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