Obteniendo todas las fechas de lunes y martes para el próximo año.

Necesito mostrar una lista de fechas (solo lunes y martes) para los próximos 12 meses a partir de la fecha actual, así:

Enero 2010
Mar 12 ene 2010
Lun 18 de enero de 2010
Mar 19 ene 2010
Lun 25 ene 2010
Feb 2010
Mar 02 feb 2010
Lun 08 feb 2010
Mar 09 feb 2010
Lun 15 feb 2010
Mar 16 feb 2010
Lun 22 feb 2010
Mar 2010
Mar 09 mar 2010
Lun 15 mar 2010
Mar 16 mar 2010
...

Siendo nuevo en PHP pensétiempo de juego y recorrer las próximas 52 semanas es la mejor manera de avanzar.

$blockedDatesInput = "08 Mar 2010,12 Apr 2010"; // dont show these dates
$blockedDates = explode ("," , $blockedDatesInput); // convert to array
$currentMonth = ""; // current month marker

// loop over the next 52 weeks to find Mondays and Tuesdays
for($i=0; $i<=52; $i++){
// build the month header
$monthReference = date("M Y", strtotime('+'.$i.' Week'));

// check if date exists in $blockeddate
if (!in_array(date("d M Y", strtotime('+'.$i.' Monday')), $blockedDates) || 
    !in_array(date("d M Y", strtotime('+'.$i.' Tuesday')), $blockedDates) ) {
     // check if we have to show a new month
     if(strcmp($monthReference, $currentMonth) <> 0){
       echo $monthReference.'<br />',"\n";
     }else{
      // output the dates
      echo date("D d M Y", strtotime('+'.$i.' Monday')).'<br />',"\n";
      echo date("D d M Y", strtotime('+'.$i.' Tuesday')).'<br />',"\n";
     }
       $currentMonth = date("M Y", strtotime('+'.$i.' Week'));
   }
}

Sin embargo, la salida de mi código es

Enero 2010
Lun 18 de enero de 2010
Mar 12 ene 2010
Lun 25 ene 2010
Mar 19 ene 2010
Feb 2010
Lun 08 feb 2010
Mar 02 feb 2010
Lun 15 feb 2010
Mar 09 feb 2010
Lun 22 feb 2010
Mar 16 feb 2010
Mar 2010
Lun 08 mar 2010
Mar 02 mar 2010
Lun 15 mar 2010
Mar 09 mar 2010
Lun 22 mar 2010
Mar 16 mar 2010
Lun 29 mar 2010
Mar 23 mar 2010

Como se puede ver, las fechas no están en el orden correcto y estoy en una pérdida en la que me estoy equivocando aquí.

¿Hay una manera más elegante / simple de resolver esto?

La versión de PHP utilizada es 5.2.11 y no hay posibilidad de ir a 5.3 pronto :-(

Gracias por tu ayuda.

Código debajo de la modificación como lo sugiere Aly. Se cambió la fecha de la computadora del martes 12/01/2010 al miércoles 13/01/2010 para probar la salida.

$blockedDatesInput = "08 Mar 2010,12 Apr 2010"; // dont show these dates
$blockedDates = explode ("," , $blockedDatesInput); // convert to array
$currentMonth = ""; // current month marker

// loop over the next 52 weeks to find Mondays and Tuesdays
for($i=0; $i<=52; $i++){
// build the month header
$monthReference = date("M Y", strtotime('+'.$i.' Week'));

// check if date exists in $blockeddate
if (!in_array(date("d M Y", strtotime('+'.$i.' Monday')), $blockedDates) || 
    !in_array(date("d M Y", strtotime('+'.$i.' Tuesday')), $blockedDates) ) {
     // check if we have to show a new month
     if(strcmp($monthReference, $currentMonth) <> 0){
       echo $monthReference.'<br />',"\n";
     }else{
      // output the dates (changed the order as suggested by Aly)
      echo date("D d M Y", strtotime('+'.$i.' Tuesday')).'<br />',"\n";
      echo date("D d M Y", strtotime('+'.$i.' Monday')).'<br />',"\n";          
     }
       $currentMonth = date("M Y", strtotime('+'.$i.' Week'));
   }
}

Salida de nuevo en el orden incorrecto.

Enero 2010
Mar 19 ene 2010
Lun 18 de enero de 2010
Mar 26 ene 2010
Lun 25 ene 2010
Feb 2010
Mar 09 feb 2010
Lun 08 feb 2010
Mar 16 feb 2010
Lun 15 feb 2010
Mar 23 feb 2010
Lun 22 feb 2010

Respuestas a la pregunta(4)

Su respuesta a la pregunta