scandir() to sort by date modified

后端 未结 3 1699
感动是毒
感动是毒 2020-11-27 16:26

I\'m trying to make scandir(); function go beyond its written limits, I need more than the alpha sorting it currently supports. I need to sort the scandir

3条回答
  •  有刺的猬
    2020-11-27 17:10

    Alternative example..

    $dir = "/home/novayear/public_html/backups";
    chdir($dir);
    array_multisort(array_map('filemtime', ($files = glob("*.{sql,php,7z}", GLOB_BRACE))), SORT_DESC, $files);
    foreach($files as $filename)
    {
      echo "".substr($filename, 0, -4)."
    "; }

提交回复
热议问题