bug76800.phpt 395 B

1234567891011121314
  1. --TEST--
  2. Bug #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
  6. foreach($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--
  13. See key 1
  14. See key 3