在多维数组中查找匹配键并将它们存储在新数组中

时间:2016-11-23 23:08:46

标签: php arrays multidimensional-array

我想解析一个多维数组并将所有匹配的键存储到它们自己的数组中。

输入数组:

    array (
    [Items] => Array (
        [0] => AS1585.AGG
        [1] => AS1585.AGG
        [2] => ZBRK-1776
        [3] => ZBRK-2076
        [4] => ZBRK-3001
    )
    [Qty2] => Array (
        [0] => 5
        [1] => 5
        [2] => 5
        [3] => 5
        [4] => 6
    )
    [Cost] => Array (
        [0] => $351.00
        [1] => $351.00
        [2] => $437.00
        [3] => $380.00
        [4] => $358.00
    )
    [TotalCubes2] => Array (
        [0] => 168.40
        [1] => 168.40
        [2] => 186.05
        [3] => 161.25
        [4] => 140.70
    )
    [TotalCost2] => Array (
        [0] => $1755.00
        [1] => $1755.00
        [2] => $2185.00
        [3] => $1900.00
        [4] => $2148.00
    )
)

期望的输出:

Array (
    [Items] => AS1585.AGG
    [Qty2] => 5
    [Cost] => $351.00
    [TotalCubes2] => 168.40
    [TotalCost2] => $1755.00
)

0 个答案:

没有答案