I have a array what I'm fetching with mysql query per row, each containing the same indexes and it looks as it follows
array(
0=> array(
'order_nr'=> 123,
'order_date' => '2013-01-29 00:00:00',
'prod_name' => 'prod_1',
'prod_value' => 1200
)
1=> array(
'order_nr'=> 123,
'order_date' => '2013-01-29 00:00:00' ,
'prod_name' => 'prod_2',
'prod_value' => 2100
)
)
I would like to merge theme and make the sum of prod_value and creating a new array on prod_name and at the end I would have singe array. How would I do this in php or what would be the best workaround in this case
array(
'order_nr'=> 123,
'order_date'=>'2013-01-29 00:00:00',
'prod_name'=> array('prod_1', 'prod_2')
'prod_value' => 3300
)
GROUP BYon the database side, not on the PHP side