How to group multidimension array by key with php? -
i have array:
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 ) )
the goal convert 1 dimension array result as:
array([type]=>activation [mount]=>78,130,210,190,250,300,330), array([type]=>revenue [mount]=>100,310,200,400,470,310,600)
there simple way php4 , newer, function called array_merge_recursive(). merge sub arrays single one. if there identical keys, merged single key array value.
see full documentation here.
Comments
Post a Comment