合并多维数组中的互补结果

时间:2017-06-22 18:59:54

标签: php arrays multidimensional-array

如何在多维数组中合并结果?例如,如果我想制作餐馆指南并从2个来源抓取结果,并希望合并补充字段,如此示例(评级)并保留两个来源。

    Array ( 
            [0] => Array ( 
                 [source] => Google 
                 [name] => Restaurant X
                 [lat] => -22.7
                 [lng] => -47.6
                 [google_rating] => 3
                 [facebook_rating] =>
           ) 
           [1] => Array ( 
                 [source] => Facebook 
                 [name] => Restaurant X
                 [lat] => -22.7
                 [lng] => -47.6
                 [google_rating] =>
                 [facebook_rating] => 4

           )
)

预期结果如下:

[0] => Array ( 
                 [source] => Google,Facebook
                 [name] => Restaurant X
                 [lat] => -22.7
                 [lng] => -47.6
                 [google_rating] => 3
                 [facebook_rating] => 4

           )

0 个答案:

没有答案