mirror of
https://github.com/php/php-src.git
synced 2024-12-03 23:05:57 +08:00
7aacc705d0
Closes GH-5958
28 lines
405 B
PHP
28 lines
405 B
PHP
--TEST--
|
|
Bug #40705 (Iterating within function moves original array pointer)
|
|
--FILE--
|
|
<?php
|
|
function doForeach($array)
|
|
{
|
|
foreach ($array as $k => $v) {
|
|
// do stuff
|
|
}
|
|
}
|
|
|
|
$foo = array('foo', 'bar', 'baz');
|
|
var_dump(key($foo));
|
|
doForeach($foo);
|
|
var_dump(key($foo));
|
|
foreach ($foo as $k => $v) {
|
|
var_dump($k);
|
|
}
|
|
var_dump(key($foo));
|
|
?>
|
|
--EXPECT--
|
|
int(0)
|
|
int(0)
|
|
int(0)
|
|
int(1)
|
|
int(2)
|
|
int(0)
|