Changes key of an array element

Creates an element with new key and removed old one. Read more.

php
fork add to bundle source
function change_key(&$array, $old_key, $new_key) { $array[$new_key] = $array[$old_key]; unset($array[$old_key]); }

usage

load_function('change_key'); $array = [ 'a' => 543, 'b' => 234 ]; change_key($array, 'b', 'c'); print_r($array); // Array // ( // [a] => 543 // [c] => 234 // )
← how to use this in app?
create log ...inout