0

私はこの配列を持っています:

Array
(
    [0] => Array
        (
            [0] => 78
            [mount] => 78
            [1] => activation
            [type] => activation
            [2] => 2013-10-01
            [insertdate] => 2013-10-01
        )

    [1] => Array
        (
            [0] => 130
            [mount] => 130
            [1] => activation
            [type] => activation
            [2] => 2013-10-02
            [insertdate] => 2013-10-02
        )

    [2] => Array
        (
            [0] => 210
            [mount] => 210
            [1] => activation
            [type] => activation
            [2] => 2013-10-03
            [insertdate] => 2013-10-03
        )

    [3] => Array
        (
            [0] => 190
            [mount] => 190
            [1] => activation
            [type] => activation
            [2] => 2013-10-04
            [insertdate] => 2013-10-04
        )

    [4] => Array
        (
            [0] => 250
            [mount] => 250
            [1] => activation
            [type] => activation
            [2] => 2013-10-05
            [insertdate] => 2013-10-05
        )

    [5] => Array
        (
            [0] => 300
            [mount] => 300
            [1] => activation
            [type] => activation
            [2] => 2013-10-06
            [insertdate] => 2013-10-06
        )

    [6] => Array
        (
            [0] => 330
            [mount] => 330
            [1] => activation
            [type] => activation
            [2] => 2013-10-07
            [insertdate] => 2013-10-07
        )

    [7] => Array
        (
            [0] => 100
            [mount] => 100
            [1] => revenue
            [type] => revenue
            [2] => 2013-10-01
            [insertdate] => 2013-10-01
        )

    [8] => Array
        (
            [0] => 310
            [mount] => 310
            [1] => revenue
            [type] => revenue
            [2] => 2013-10-02
            [insertdate] => 2013-10-02
        )

    [9] => Array
        (
            [0] => 200
            [mount] => 200
            [1] => revenue
            [type] => revenue
            [2] => 2013-10-03
            [insertdate] => 2013-10-03
        )

    [10] => Array
        (
            [0] => 400
            [mount] => 400
            [1] => revenue
            [type] => revenue
            [2] => 2013-10-04
            [insertdate] => 2013-10-04
        )

    [11] => Array
        (
            [0] => 470
            [mount] => 470
            [1] => revenue
            [type] => revenue
            [2] => 2013-10-05
            [insertdate] => 2013-10-05
        )

    [12] => Array
        (
            [0] => 310
            [mount] => 310
            [1] => revenue
            [type] => revenue
            [2] => 2013-10-06
            [insertdate] => 2013-10-06
        )

    [13] => Array
        (
            [0] => 600
            [mount] => 600
            [1] => revenue
            [type] => revenue
            [2] => 2013-10-07
            [insertdate] => 2013-10-07
        )

)

目標は、次のようになる 1 次元配列に変換することです。

array([type]=>activation [mount]=>78,130,210,190,250,300,330),
array([type]=>revenue [mount]=>100,310,200,400,470,310,600)
4

2 に答える 2

0

PHP4 以降でこれを行うには本当に簡単な方法があります。この関数は array_merge_recursive() と呼ばれます。サブ配列を単一の配列にマージします。同一のキーが存在する場合、これは値として配列を持つ 1 つのキーにマージされます。

ここで完全なドキュメントを参照してください。

于 2013-10-07T07:55:14.197 に答える