Friday, 30 August 2013

Combining Similar Data - Arrays in PHP

Combining Similar Data - Arrays in PHP

I have a 2d array such as the following:
Jan 1, 10
Jan 2, 20
Jan 2, 15
Jan 3, 20
Jan 3, 10
Jan 3, 5

And i need to create a way to scan this array, and add the numbers for
similar dates into a new array, so that:
Jan 1, 10
Jan 2, 35
Jan 3, 35

What is the quickest way to accomplish this? Thank you!

No comments:

Post a Comment