I have the following array:
array(9) {
[0]=>
object(stdClass)#2477 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Tratamento Odontológico"
["value"]=>
string(15) "333.33333333333"
}
[1]=>
object(stdClass)#2478 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Tratamento Odontológico"
["value"]=>
string(15) "333.33333333333"
}
[2]=>
object(stdClass)#2479 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Tratamento Odontológico"
["value"]=>
string(15) "333.33333333333"
}
[3]=>
object(stdClass)#2480 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Tratamento Odontológico"
["value"]=>
string(15) "333.33333333333"
}
[4]=>
object(stdClass)#2481 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Tratamento Odontológico"
["value"]=>
string(15) "333.33333333333"
}
[5]=>
object(stdClass)#2482 (4) {
["type"]=>
string(2) "out"
["category"]=>
string(24) "Contabilidade"
["value"]=>
string(15) "85.106382978723"
}
[6]=>
object(stdClass)#2483 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Celular"
["value"]=>
string(15) "100"
}
[7]=>
object(stdClass)#2484 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Celular"
["value"]=>
string(15) "100"
}
[8]=>
object(stdClass)#2485 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Celular"
["value"]=>
string(15) "100"
}
}
I need to group the category field so that only 1 item of each different category type is returned and add the values of each category. This needs to return, for example:
array(3) {
[0]=>
object(stdClass)#2477 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Tratamento Odontológico"
["value"]=>
string(16) "1666,666666667"
}
[1]=>
object(stdClass)#2478 (4) {
["type"]=>
string(2) "out"
["category"]=>
string(24) "Contabilidade"
["value"]=>
string(15) "85.106382978723"
}
[2]=>
object(stdClass)#2479 (4) {
["type"]=>
string(2) "in"
["category"]=>
string(24) "Celular"
["value"]=>
string(15) "300"
}
}
I've already researched and tried several ways to do this, but I'm really very lost and need help with this, thank you in advance!