3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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);
based on VFQRV
Output for 4.3.0 - 7.1.0
array(3) { ["a"]=> string(1) "a" [0]=> string(1) "b" ["c"]=> string(1) "c" }