I have an array with two values, userID and a transaction value. The userID is NOT unique, and I would like a list/array of the same values, just "summed up". Meaning: If a userID has more occurrences, then I would like the 2nd value (the transaction) to be added together. I will post an example.
$a = array(
1 => 1,
1 => 2,
2 => 3,
2 => -17
);
The result after running whatever function is needed, is:
$a = array(
1 => 3,
2 => -14
);
So no duplicate userID's, and the transaction values are added to the one entry of the userID.
I am getting these values from a SQL database, so if I can solve this with a SQL view or something, that would also go as a valid answer :-)
1 => 2, 2 => -17with no dupes. - Marc B