I have to sum some columns of an multidimensional array, and i`m stucked for 3 days at it. My array is like this:
$items = [
0 => [
0 => [
'category' => 'CATEGORY ONE',
'goal' => 12,
'reached' => '14',
'points' => '148',
],
1 => [
'category' => 'CATEGORY TWO',
'goal' => 12,
'reached' => '14',
'points' => '148',
]
],
1 => [
0 => [
'category' => 'CATEGORY ONE',
'goal' => 12,
'reached' => '14',
'points' => '148',
],
1 => [
'category' => 'CATEGORY TWO',
'goal' => 12,
'reached' => '14',
'points' => '148',
]
]
];
i was no abble to parse this data to get the sum of values of each category so it have to return like this:
$items = [
0 => [
'category' => 'CATEGORY ONE',
'goal' => 24,
'reached' => '48',
'points' => '296',
],
1 => [
'category' => 'CATEGORY TWO',
'goal' => 12,
'reached' => '14',
'points' => '296',
]];
'reached' => '48'calculated?