I have an array of indexes that I want to sort my other array:
$order = [7, 2, 1, 4];
$array = [
1 => "O",
2 => "T"
4 => "F"
7 => "S"
]
How can I order the $array
based on $order
array, so that the output is..
$array = [
7 => "S",
2 => "T"
1 => "O",
4 => "F"
]
As far as I read, something other than for loop is much preferred