scandir() to sort by date modified

function scan_dir($dir) {
    $ignored = array('.', '..', '.svn', '.htaccess');

    $files = array();    
    foreach (scandir($dir) as $file) {
        if (in_array($file, $ignored)) continue;
        $files[$file] = filemtime($dir . "https://stackoverflow.com/" . $file);
    }

    arsort($files);
    $files = array_keys($files);

    return ($files) ? $files : false;
}

Leave a Comment