php-src/Zend/tests/bug40705.phpt
Dmitry Stogov e13b4c2c4e Fixed bug #40705 (Iterating within function moves original array pointer)
Fixed bug #40509 (key() function changed behaviour if global array is used within function)
2007-07-24 19:24:40 +00:00

27 lines
396 B
PHP
Executable File

--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)
NULL