3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php set_time_limit(1); $arr = ['a' => 'apple', 'b' => 'banana']; $child = &$arr; $i = 1; foreach ($child AS $key => $fruit) { echo $i; $child[$i] = $fruit; unset($child[$key]); $i++; } var_dump($child);
based on 4DYmO