PHP根据键合并两个具有匹配值的数组

时间:2017-08-04 20:17:40

标签: php

我有两个阵列;第一个有一组指令删除第二个数组中的帖子。

第一个数组

Array
(
    [0] => Array
        (
            [post_delete] => 1
            [post_key] => YXdsrP
        )

    [1] => Array
        (
            [post_delete] => 1
            [post_key] => 1jV37Q
        )

    [2] => Array
        (
            [post_delete] => 1
            [post_key] => JvlMIL
        )
)

第二个数组

Array
(
    [0] => Array
        (
            [post_id] => 598490e010c7c25738677bd0
            [post_key] => TbjI1A
        )

    [1] => Array
        (
            [post_id] => 598490c210c7c24938677bd1
            [post_key] => YXdsrP
        )

    [2] => Array
        (
            [post_id] => 598490a41908cd2619677bd0
            [post_key] => myYIKh
        )

    [3] => Array
        (
            [post_id] => 59847e2a10c7c2155ff80e82
            [post_key] => 1jV37Q
        )

    [4] => Array
        (
            [post_id] => 59847e076bf29fec56f274c2
            [post_key] => JvlMIL
        )
)

我希望将这两个数组合并创建一个基于匹配每个数组中标记为“post_key”的键,同时从第二个数组中删除其他数组。我正在寻找的最终结果。

Array
(
    [0] => Array
        (
            [post_delete] => 1
            [post_key] => YXdsrP
            [post_id] => 598490c210c7c24938677bd1
        )

    [1] => Array
        (
            [post_delete] => 1
            [post_key] => 1jV37Q
            [post_id] => 59847e2a10c7c2155ff80e82
        )

    [2] => Array
        (
            [post_delete] => 1
            [post_key] => JvlMIL
            [post_id] => 59847e076bf29fec56f274c2
        )
)

0 个答案:

没有答案