How can I sum this array by value? Just sum value of [jumlah] group by [Kondisi].
Array
(
[0] => stdClass Object
(
[Kondisi] => one
A sample code can be:
$sums = [];
// `$objects` is your initial array
foreach ($objects as $object) {
// here we check if key `$object->Kondisi` exists in `$sums` array
if (empty($sums[$object->Kondisi])) {
// if `no` - this is new object, store it as is
$sums[$object->Kondisi] = $object;
} else {
// if `yes` - add `jumlah` value to existing `jumlah` property
$sums[$object->Kondisi]->jumlah += $object->jumlah;
}
}
// use `array_values` to get 0-indexed array
print_r(array_values($sums));