How do I display folders in date of creation order?

前端 未结 3 495
说谎
说谎 2021-01-22 12:41

I am new to PHP and developing a project called BaboonHut.com, I am coding it in PHP as the best way to learn is by just diving in. Anyway to the question, the snippet of code b

3条回答
  •  清歌不尽
    2021-01-22 13:31

    This will grab a list of files from a directory put them into an array then sort the array by date.

     $resdir,
            "time" => filectime($resdir)
        ];
    }
    
    // Sort files by date
    usort($files, function($a, $b){
        return $b["time"] - $a["time"];
    });
    
    foreach($files as $resdir) {
        $resdir = str_replace($dir, '', $resdir);
        echo <<
        

    $resdir

    HTML; readfile('resources/'. $resdir .'/description.txt'); echo << More Information

    HTML; }

提交回复
热议问题