sort directories by date

Discussion in 'PHP' started by bumbar, Feb 9, 2008.

  1. #1
    hallo!

    Is there any method who sort directories by date?:D

    Thanks!
     
    bumbar, Feb 9, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    $dir = 'path/to/dir/';
    
    $subirs = glob("{$dir}*");
    $dates = array_map('filemtime', $subdirs);
    
    array_multisort($dates, SORT_NUMERIC, SORT_DESC, $subdirs);
    
    print_r($subdirs);
    
    PHP:
    I'm on my phone right now, so I couldn't test it. But you get the idea.
     
    nico_swd, Feb 9, 2008 IP