I have array :
Array
(
[0] => 166
[role_code] => new role test
)
I want to change [0] into [menu_id]. How i can change it on PHP code?
You could use the union operator and then unset index 0:
$array = [ 'menu_id' => $array[0] ] + $array;
unset($array[0]);
You can just assign the value to a new item and unset the previous one.
$array['menu_id'] = $array[0];
unset($array[0]);