3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array('a' => 'a', 'b' => 'b', 'c' => 'c'); $oldKey = 'b'; $newKey = 'new'; array_splice($arr, 1, 1, array($newKey => $arr[$oldKey])); var_dump($arr);

preferences:
41.32 ms | 402 KiB | 5 Q