结合类似的数据 - 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!

Try this

<?php

// array of monthdate structure
$monthdate = array();
$monthdate[] = array('date'=>'Jan 1','num'=>10);
$monthdate[] = array('date'=>'Jan 2','num'=>20);
$monthdate[] = array('date'=>'Jan 2','num'=>15);    
$monthdate[] = array('date'=>'Jan 3','num'=>20);
$monthdate[] = array('date'=>'Jan 3','num'=>10);             
// begin the iteration for grouping date and calculate the num
$sumofnum = array();
foreach($monthdate as $month) {
    $index = month_exists($month['date'], $sumofnum);
    if ($index < 0) {
        $sumofnum[] = $month;
    }
    else {
        $sumofnum[$index]['num'] +=  $month['num'];
    }
}
print_r($sumofnum); //display 

// for search if a monthdate has been added into $sumofnum, returns the key (index)
function month_exists($monthname, $array) {
    $result = -1;
    for($i=0; $i<sizeof($array); $i++) {
        if ($array[$i]['date'] == $monthname) {
            $result = $i;
            break;
        }
    }
    return $result;
}