Ver Mensaje Individual
  #6 (permalink)  
Antiguo 02/11/2015, 06:53
hechicerd0
 
Fecha de Ingreso: julio-2015
Ubicación: Barcelona
Mensajes: 93
Antigüedad: 8 años, 9 meses
Puntos: 3
Respuesta: Ordenar un array multidimensional de fechas

Te dejo un ejemplo y intentas hacerlo con tu problema:

Código PHP:
Ver original
  1. $fechas_nacimiento = array(
  2.     array(
  3.         'nombre' => 'Paco',
  4.         'fecha'  => '22-12-2012'
  5.     ),
  6.     array(
  7.         'nombre' => 'Luis',
  8.         'fecha'  => '30-08-2012'
  9.     ),
  10.     array(
  11.         'nombre' => 'María',
  12.         'fecha'  => '25-01-2013'
  13.     )
  14. );
  15.  
  16. function ordenar( $a, $b ) {
  17.     return strtotime($a['fecha']) - strtotime($b['fecha']);
  18. }
  19.  
  20. function mostrar_array($datos) {
  21.     foreach($datos as $dato)
  22.         echo "{$dato['fecha']} -&gt; {$dato['nombre']}<br/>";
  23. }
  24.  
  25.  
  26. usort($fechas_nacimiento, 'ordenar');
  27.  
  28. mostrar_array($fechas_nacimiento);