I have two keys and want to swap them in a multidimensional array.
I Have referred these Swap array values with php, How to swap two values in array with indexes? references but didn't get any help.
I have this array,
[
'box-a' => 'email',
'box-b' => 'job',
'box-c' => 'company',
'box-d' => 'candidate',
'box-e' => 'calender',
'box-f' => 'smartlist',
'box-g' => 'analytics',
]
And I want to swap two array keys, box-b
and box-e
but the array values should remain as it is.
I have tried this,
list($array[$swap_a], $array[$swap_b]) = array($array[$swap_b], $array[$swap_a]);
But didn't get success. Where am I wrong?