3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $x = array('item1', 'item2'); foreach ($x as $key => $value) { echo $key.' '.$value."\n"; if ($key == 0) unset($x[$key]); if ($key == 1) $x[$key] = 'item2changed'; } print_r($x);
based on 9c21R
Output for 4.3.0 - 7.1.0
0 item1 1 item2 Array ( [1] => item2changed )