php根据其他数组的顺序对数组重新排序

php根据其他数组的顺序对数组重新排序,php,arrays,sorting,Php,Arrays,Sorting,鉴于此阵列: Array ( [0] => Array ( [title] => this is the newest post [ssm_featured_post_id] => 70 ) [1] => Array ( [title] => sdfsfsdf [ssm_featured_post_id] => 63 ) [2] => Array

鉴于此阵列:

Array
(
[0] => Array
    (
        [title] => this is the newest post
        [ssm_featured_post_id] => 70
    )

[1] => Array
    (
        [title] => sdfsfsdf
        [ssm_featured_post_id] => 63
    )

[2] => Array
    (
        [title] => test
        [ssm_featured_post_id] => 49
    )

[3] => Array
    (
        [title] => Hello world!
        [ssm_featured_post_id] => 1
    )
)

ssm_featured_post_id值对应于第二个数组中数组项的值。 我希望第一个数组项的顺序与第二个数组项的顺序相同

Array
(
    [1] => 63
    [0] => 70
    [3] => 1
    [2] => 49
)
因此,排序后的结果将是

Array
(
[0] => Array
    (

        [title] => sdfsfsdf
        [ssm_featured_post_id] => 63
    )

[1] => Array
    (
        [title] => this is the newest post
        [ssm_featured_post_id] => 70
    )

[2] => Array
    (
        [title] => Hello world!
        [ssm_featured_post_id] => 1

    )

[3] => Array
    (
        [title] => test
        [ssm_featured_post_id] => 49
    )

)

您可能想要签出,特别是给出的第三个示例。其思想是基于多维数组的“列”创建数组,然后同时对它们进行排序,然后将结果放回原始数组。

更简单的方法是使用并编写一个函数,该函数使用第二个表来比较第一个表中的两个值。

从技术上讲,第二个数组不符合您在输出中显示的顺序。由于数组(1、0、3、2)的索引顺序不正确,因此值的直观显示顺序(63、70、1、49)无关紧要。我想这只是一个格式错误?解决方案在这里我找到了另一个线程,它回答了我的问题,当我回来时,我看到了所有这些可以接受的答案。我该怎么办?接受一个。它们都能解决你的问题。选择您认为更适用于您的问题的解决方案。这是一个解决方案,它是否“更简单”取决于实现。虽然答案是正确的,投票。是的,也许有一个更简单的解决方案,但在我看来,这将是一个我会使用的