I'm facing a problem with multiple array calculation. I am using database mysql and operation language is PHP. When I'm fetching an result from database result show multiple array with fixed key and value. When one array key code value is same as separate array key code value then this array combine to one with sum quantities and prices. This is fetching result from database.
['code'=>'aaa','name'=>'a','qty'=>20,'price'=>12.00],
['code'=>'bbb','name'=>'b','qty'=>20,'price'=>12.00],
['code'=>'ccc','name'=>'c','qty'=>20,'price'=>12.00],
['code'=>'aaa','name'=>'a','qty'=>20,'price'=>12.00],
['code'=>'ddd','name'=>'d','qty'=>20,'price'=>12.00],
['code'=>'ccc','name'=>'c','qty'=>5,'price'=>8.00],
['code'=>'bbb','name'=>'b','qty'=>15,'price'=>10.00],
['code'=>'ggg','name'=>'g','qty'=>20,'price'=>12.00],
and I want to customize this result this format.
['code'=>'aaa','name'=>'a','qty'=>40,'price'=>24.00],
['code'=>'bbb','name'=>'b','qty'=>35,'price'=>22.00],
['code'=>'ccc','name'=>'c','qty'=>25,'price'=>20.00],
['code'=>'ddd','name'=>'d','qty'=>20,'price'=>12.00],
['code'=>'ggg','name'=>'g','qty'=>20,'price'=>12.00],
Please help me to solve this problem . I tried a lot but didn't get any solution.