xref: /PHP-8.0/Zend/tests/bug76800.phpt (revision 7aacc705)
1--TEST--
2Bug #76800 (foreach inconsistent if array modified during loop)
3--FILE--
4<?php
5$arr = [1 => 1, 3 => 3];           // [1 => 1, 2 => 3] will print both keys
6foreach($arr as $key => &$val) {   // without & will print both keys
7    echo "See key {$key}\n";
8    $arr[0] = 0;                   // without this line will print both keys
9    unset($arr[0]);
10}
11?>
12--EXPECT--
13See key 1
14See key 3
15