Well, that looks like a bunch if fun.
I believe you might be able to just create the actualy effects while you create the array.
But, since I don't have your source in front of me, I'll assume that you did in fact have no other choice but to twice loop through an array as I know there are times when it is unavoidable.
So ....
<?
$array = array ("2001-12-01","2001-12-06","2002-01-01","2002-01-07","2002-02-01","2002-02-11","2002-03-16");
for($i=1;$i<=12;$i++) {
if ($i<10) { $i = "0".$i; }
for($x=0;$x<count($array);$x++) {
if (ereg('[0-9]{4}-'.$i.'-[0-9]{2}',$array[$x])) {
$sorted[$i][count($sorted[$i])] = $array[$x];
}
}
}
//sorted now contains all 12 months and all dates found for each month, sorted by month.
print_r($sorted);
//call this month like so..
foreach($sorted[date('m')] as $key=>$val) {
echo $key . ": " . $val;
}
?>