xref: /PHP-8.0/Zend/tests/bug40705.phpt (revision 7aacc705)
1--TEST--
2Bug #40705 (Iterating within function moves original array pointer)
3--FILE--
4<?php
5function doForeach($array)
6{
7    foreach ($array as $k => $v) {
8        // do stuff
9    }
10}
11
12$foo = array('foo', 'bar', 'baz');
13var_dump(key($foo));
14doForeach($foo);
15var_dump(key($foo));
16foreach ($foo as $k => $v) {
17    var_dump($k);
18}
19var_dump(key($foo));
20?>
21--EXPECT--
22int(0)
23int(0)
24int(0)
25int(1)
26int(2)
27int(0)
28