我有 2 个数组,1 个保存要显示的数据,另一个保存订单。
以下数组将在 foreach 循环中使用以显示:
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'
)
此数组包含排序位置:
array(
2, 4, 7, 3
)
我想根据关联数组中的值对第一个数组进行排序,其中键是与第二个数组匹配的 id。
预期输出:
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'
)