3v4l.org

run code in 300+ PHP versions simultaneously
<?php set_time_limit(1); $arr = ['f' => 'apple', 'g' => 'banana']; $child = &$arr; $i = 1; foreach ($child AS $key => $fruit) { $child[$i] = $fruit; unset($child[$key]); $i++; } var_dump($child);

preferences:
86.74 ms | 402 KiB | 5 Q