如何组合两个数组,将元素分配为一个。 PHP

时间:2018-06-06 06:18:56

标签: php arrays

我打破了我的想法。我需要连接来自不同数据表的三个数据集。一个ID有第二个密钥,第二个到第三个密钥(ID - >如果UF_DRIVER有ID - > NAME1或ID - >如果UF_DRIVER有ID - > NAME2)

有三个数组:$arItems$arProps1以及$arProps2

第一个数组$arItems的元素:

Array([0] => 2707) Array([0] => 2708)

第二个数组$arProps1的元素:



Array
(
    [0] => Array
        (
            [ID] => 2707
            [UF_VISITOR] => 1909
            [UF_DRIVER] => 
        )
    [0] => Array
        (
            [ID] => 2708
            [UF_VISITOR] =>
            [UF_DRIVER] => 1910
        )
)




第三个数组的元素$ arProps2:



Array
(
    [0] => Array
        (
            [ID] => 1909
            [UF_FIRSTNAME] => NAME1
        )

    [1] => Array
        (
            [ID] => 1910
            [UF_FIRSTNAME] => NAME2
        )

    [2] => Array
        (
            [ID] => 2015
            [UF_FIRSTNAME] => NAME3
        )
)




如何将这些数组元素合并到一个数组元素中?:



Array([0] => 2707 => Array(
                          [0] => Array(
                          
                          [ID] => 2707
                          [UF_VISITOR] => 1909
                          [UF_DRIVER] => 
                                       ) => Array ([0] => Array([ID] => 1909
                                                                [UF_FIRSTNAME] => NAME1
))

Array([0] => 2708 => Array(
                          [0] => Array(
                          
                          [ID] => 2708
                          [UF_VISITOR] =>
                          [UF_DRIVER] => 1910
                                       ) => Array ([0] => Array([ID] => 1910
                                                                [UF_FIRSTNAME] => NAME2
))




0 个答案:

没有答案