I have a problem, that might seem very basic but I cannot get a simple solution and I think there must be one.
I have an array that I need to bring in a specific order.
$arr1 = [
['code' => 555, 'amount' => 100],
['code' => 555, 'amount' => 200],
['code' => 555, 'amount' => 300],
['code' => 222, 'amount' => 100],
['code' => 222, 'amount' => 200],
['code' => 222, 'amount' => 300],
['code' => 777, 'amount' => 100],
['code' => 777, 'amount' => 200],
['code' => 777, 'amount' => 300]
]
And I would like it to bring it in this order:
$sortedArr = [
['code' => 555, 'amount' => 100],
['code' => 222, 'amount' => 100],
['code' => 777, 'amount' => 100],
['code' => 555, 'amount' => 200],
['code' => 222, 'amount' => 200],
['code' => 777, 'amount' => 200],
['code' => 555, 'amount' => 300],
['code' => 222, 'amount' => 300],
['code' => 777, 'amount' => 300]
]
If this helps, I do have another array with the exact order of the codes
$codes = [555, 222, 777];
Any help is appreciated! Thanks!