使用PHP

时间:2015-08-21 22:38:48

标签: php arrays

我有2个数组包括数组输入和数组输出,我想将它们组合在一起,它们具有相同的名称将具有输入,输出,如果不相同,则输入或输出为0.。

我如何得到你想要的结果,希望每个人都帮助我。非常感谢。

阵列A

[0] => Array
    (
        [part_code] => 222
        [input] => 1
    )

[1] => Array
    (
        [part_code] => A1015
        [input] => 3
    )

[2] => Array
    (
        [part_code] => CON0000258
        [input] => 1
    )

[3] => Array
    (
        [part_code] => CON0000300
        [input] => 30
    )

[4] => Array
    (
        [part_code] => DOO0000124
        [input] => 15
    )

[5] => Array
    (
        [part_code] => DOO0000125
        [input] => 1
    )

[6] => Array
    (
        [part_code] => ESC0000047
        [input] => 20
    )

[7] => Array
    (
        [part_code] => Test111
        [input] => 1
    )

阵列B

[0] => Array
    (
        [part_code] => 3RH002
        [output] => 1
    )

[1] => Array
    (
        [part_code] => CON0000300
        [output] => 1
    )

[2] => Array
    (
        [part_code] => DOO0000124
        [output] => 2
    )

[3] => Array
    (
        [part_code] => DOO0000125
        [output] => 1
    )

[4] => Array
    (
        [part_code] => Test111
        [output] => 4
    )

[5] => Array
    (
        [part_code] => TOO0000034
        [output] => 1
    )

[6] => Array
    (
        [part_code] => XAA502C1_TEST
        [output] => 1
    )

数组结果

[0] => Array ( [part_code] => 222 [input] => 1  [output] => 0)
[1] => Array ( [part_code] => A1015 [input] => 3 [output] => 0 )
[2] => Array ( [part_code] => CON0000258 [input] => 1 [output] => 0)
[3] => Array ( [part_code] => CON0000300 [input] => 30 [output] => 1 )
[4] => Array ( [part_code] => DOO0000124 [input] => 15 [output] => 2)
[5] => Array ( [part_code] => DOO0000125 [input] => 1 [output] => 1 )
[6] => Array ( [part_code] => ESC0000047 [input] => 20 [output] => 0 )
[7] => Array ( [part_code] => Test111 [input] => 1 [output] => 4 )       
[8] => Array ( [part_code] => 3RH002 [output] => 1 [input] => 0 )
[9] => Array ( [part_code] => TOO0000034 [output] => 1  [input] => 0 )
[10] => Array ( [part_code] => XAA502C1_TEST [output] => 1 [input] => 0  )

0 个答案:

没有答案