php-src/Zend/tests/foreach.phpt
Ilia Alshanetsky d9adb6715f Fixed foreach by-ref bug.
# Patch from Brian Shire
2007-04-05 23:48:43 +00:00

26 lines
274 B
PHP

--TEST--
foreach() by-ref bug
--FILE--
<?php
$foo = array(1,2,3,4);
foreach($foo as $key => &$val) {
if($val == 3) {
$foo[$key] = 0;
} else {
$val++;
}
}
var_dump($foo);
?>
--EXPECT--
array(4) {
[0]=>
int(2)
[1]=>
int(3)
[2]=>
int(0)
[3]=>
&int(5)
}