I have an array with IDs that looks like
$order_ids = array(8,9,10,4,7);
and another multidimensional array that looks like
$multiarray = [
[4, 23, 1],
[9, 66, 4],
[8, 17, 3],
];
I tried
$keys = array_flip($order_ids);
usort($multiarray, function($a, $b) use ($keys)
{
return $keys[$a] - $keys[$b[0];
});
The order_ids of the 2nd array correspond to the values in the first array. What I need to do is sort the 2nd array by the order_ids in the order they are in the 1st array.
['id'], but the array you're trying to sort is not associative. You have marked the0index as the one with the order id, so you should try[0]instead. P.S. This should be giving you Undefined index notices.