I need to group the data in my indexed array of indexed arrays by the first column values (id column). Within each group, I need to find the sum of the second column and find the sum of the third column.
Sample input:
[
[111, 5, 3],
[111, 3, 7],
[111, 2, 1],
[222, 5, 3],
]
Desired result:
[
111 => [10, 11]
222 => [5, 3]
]
You’d have to do this manually using a loop. Something like this should work:
Output:
Demo