Ver Mensaje Individual
  #8 (permalink)  
Antiguo 12/05/2012, 08:19
IXtremeLT
 
Fecha de Ingreso: julio-2011
Ubicación: Zapopan, Jal. MX
Mensajes: 316
Antigüedad: 12 años, 10 meses
Puntos: 32
Respuesta: Test de Conocimiento, problema de prueba

Sale, no había probado mi código, te lo dejo ya con una pequeña correción, hehe.


Código PHP:
Ver original
  1. function nextWDayFor($customWDays, $outputFormat)
  2. {
  3.     $incDay = 1;
  4.     while(1) {
  5.         $nextTDay = strtotime('+'.$incDay.' day');
  6.         $nextWDay = date('D', $nextTDay);
  7.         foreach ( $customWDays as $cWDay ) {
  8.             if ( $nextWDay == $cWDay ) {
  9.                 return date($outputFormat, $nextTDay);
  10.             }
  11.         }
  12.         $incDay++;
  13.     }
  14. }
  15.  
  16. $customWeekDays = array('Mon', 'Wed', 'Sat');
  17. echo nextWDayFor($customWeekDays, 'D, d \o\f M Y'); // Mon, 14 of May 2012, contando la fecha de este post.

No es necesario que ordenes los días al azar.

Saludos!

Última edición por IXtremeLT; 12/05/2012 a las 12:42