Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/05/2013, 02:05
Avatar de repara2
repara2
 
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 8 meses
Puntos: 331
Respuesta: Como ordeno titulo en php por fecha

Sería algo así:

Código PHP:
Ver original
  1. <?php
  2. //Los valores
  3. $posts = array (
  4.         0 => '2013-03-22',
  5.         1 => '2013-03-24',
  6.         2 => '2013-03-24',
  7.         3 => '2013-04-24',
  8.         4 => '2013-04-25',
  9.         5 => '2012-08-25',
  10.         6 => '2012-08-26'
  11. );
  12.  
  13. for($i = 0; $i< count($posts); $i++){
  14.     //La fecha actual es al del registro actual
  15.     $fecha_actual = $posts[$i];
  16.     //LA fecha del registro anterior si existe, si no, leo la actual
  17.     $fecha_anterior = isset($posts[$i - 1])?$posts[$i - 1]:$posts[$i];
  18.     //Si es la misma fecha, se lista
  19.     if($fecha_actual == $fecha_anterior) echo $posts[$i] . '<br/>';
  20.     //Si no, se hace un echo con un titular
  21.     else {
  22.         echo '<h3>Siguiente dia</h3>';
  23.         echo $posts[$i] . '<br/>';
  24.     }
  25.    
  26. }
  27. ?>
Salu2
__________________
Fere libenter homines, id quod volunt, credunt.