I am working with a multi-dimensional array.i want to group this array by brand_id and cat_id. In the following array [0],[1] and [2],[3] have similar brand_ids and cat_ids.i want to remove product_ids and want get sum of qtys in that object.
Array (
[0] => stdClass Object
(
[brand_id] => 1
[cat_id] => 1
[qty] => 150
[product_id] => 1
)
[1] => stdClass Object
(
[brand_id] => 1
[cat_id] => 1
[qty] => 250
[product_id] => 5
)
[2] => stdClass Object
(
[brand_id] => 4
[cat_id] => 35
[qty] => 100
[product_id] => 322
)
[3] => stdClass Object
(
[brand_id] => 4
[cat_id] => 35
[qty] => 200
[product_id] => 321
)
)
i want to rearrange array like this
Array (
[0] => stdClass Object
(
[brand_id] => 1
[cat_id] => 1
[qty] => 400
)
[1] => stdClass Object
(
[brand_id] => 4
[cat_id] => 35
[qty] => 300
[product_id] => 322
)
)