I have 2 arrays, 1 holds the data to be displayed and the other holds the order.
the following array will be used in a foreach loop to display:
array(
[Posts] =>
[0] =>
id => 7
content => 'some content'
[1] =>
id => 3,
content => 'some other content'
[2] =>
id => 4,
content => 'some more content'
[3] =>
id => 2,
content => 'some irrelevant content'
)
This array contains the sort positions:
array(
2, 4, 7, 3
)
I would like to sort the first array based on the vaulue in the associative array where the key is id that matches the second array.
Expected output:
array(
[Posts] =>
[0] =>
id => 2,
content => 'some irrelevant content'
[1] =>
id => 4,
content => 'some more content'
[2] =>
id => 7
content => 'some content'
[3] =>
id => 3,
content => 'some other content'
)