3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( 'Test' => 1, 'OtherKey' => 2 ); $keyTranslation = array( 'Test' => 'Test', 'OtherKey' => 'OtherKey' ); function test(&$arr, $keyTranslation) { foreach ($arr as $key => $value) { $arr[$keyTranslation[$key]] = $value; unset($arr[$key]); } } var_dump(test($arr, $keyTranslation));

preferences:
58.5 ms | 402 KiB | 5 Q