What is the best way to generate a condensed array like this in PHP?
<p>I have an array like:</p>

<pre><code>$arr[0] = ("1-3-2011","1","15"); //date(dd-mm-yyyy),id,amt
$arr[1] = ("1-4-2011","2","5");
$arr[2] = ("12-3-2011","6","20");
$arr[3] = ("1-3-2011","10","10");
$arr[4] = ("12-3-2011","3","10");
$arr[5] = ("1-4-2011","5","15");
$arr[6] = ("1-3-2011","7","15");
</code></pre>

<p>From this I need to generate a condensed array like</p>

<pre><code>$newarr[0] = ("1-3-2011","1,7,10","40"); 
$newarr[0] = ("1-4-2011","2,5","20");
..
...
</code></pre>

<p>Basically the first one is a multidimentional array, containing date,id, and amount. In the new array, I need to condense the previous one for each unique date, ids as a csv string for duplicate dates, and amounts added.</p>

<p>What's the most efficient way to do this, performance wise? </p>
