xref: /PHP-7.4/Zend/tests/bug76800.phpt (revision 3bc4a63f)
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--EXPECT--
12See key 1
13See key 3
14