I want to do an event archive but a very dificulty to it.

I have at this moment:

PHP Code:
<h3><?php echo $arrl["Byear"]; ?></h3>
                
            <ul class="rlinks">
            <?php for($i=-4;$i<1;$i++) { ?>
                
                    <li>
                      <a href="agend_desporto.php?modifier=<?php echo($i); ?>"><?php echo(trata_month(date(m)+$i)); ?></a>
                    </li>
                
            <?php ?>
            </ul>

where...

function trata_month($mes) {
$months = array("", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro");
return $months[$mes];
}

and I want the arcive dinamic:


if the actual month is March of 2006, I want the next output:


2005

November
December


2006

January
February
March


if June of 2006:

2006

February
March
April
May
June


Can you help me??