合并具有相同索引键的数组的子数组

时间:2017-06-22 20:29:02

标签: php arrays associative-array array-merge

我在PHP中有一个数组,如下面的第一个,我想合并所有具有相同索引键的子数组,以便合并后它们出现在一个索引键下。任何帮助都将受到赞赏.THANKYOU

阵列:

command1 | awk '1; END { print "\ntotal number of lines:", NR }'

输出应该是这样的:

            Array ( 
     [person1] => Array ( 
            [id] => 234
            [acc] => 1
        ) 
     [person1] => Array ( 
            [id] => 345
            [acc] => 2
        ) 
     [person2] => Array ( 
            [id] => 128
            [acc] => 1
        ) 
     [person3] => Array ( 
            [id] => 576
            [acc] => 5
        ) 
     [person3] => Array ( 
            [id] => 628
            [acc] => 1 
        ) 
 )

0 个答案:

没有答案