I have a PHP question for which I understand what I want to do but can't figure out how to do it. Basically I'm just trying to figure out how to calculate subtotals from within a set of data.
I have a large set of data returned in an array from a search, which could look something like this:
v125 41.25
v125 376.
028 1363.
028 4240.
006 87.
006 393.67
v113 148.
What I want to do is aggregate the second column (sales) by the first column (vendor)
I can easily get a total for everything but what I really need is subtotals for each vendor number.
I've pursued doing a foreach loop where I'm looping through the array but I can't figure out how to make it summarize the sales data by the Vendor ID.
Ultimately I want to put these subtotals into a string with their matching names so that I can append them to a specially formatted URL to send to the awesome google graphing service.
It will look something like this: http://chart.apis.google.com/chart?cht=p3&&chco=ff0000,00ff00,0000ff&chd=t:40,49,20,2,2,2,50,45&chs=450x225&chl=Avaya|Cisco|Nortel|Toshiba|NEC|Aastra|Scream|Tin%20Can
Any suggestions you have would be much appreciated.
I'm lost in the sea of PHP.
D