PHP Readdir 按创建日期排序

PHP Readdir sorting by creation date

有点基于我在网上找到的来源,但我希望它按 creation/modification 日期对视频进行排序。我尝试了多种解决方案,但似乎无法找到或想出一个我真正满意的解决方案。如果有人能指出正确的方向,我将不胜感激。

<?php
$dir = isset($_GET['cat']) ? $_GET['cat'] : 'straight';
$limit = 30; 
$page = (int)$_GET['page']?:0;
$skip = $limit * $page;
if ($handle = opendir($dir)) {
    $blacklist = array('.htaccess', '..', 'index.html');
    $skiped = 0;
    while (false !== ($file = readdir($handle))) {
    if (!in_array($file, $blacklist)) { 
    $skipped++;
    if ($skipped < $skip || $skipped >= $skip + $limit) {
        continue;
}

echo "<div class=\"video-title\">
<a href=\"\">". $file ."</a>
</div>

<div style='display: block'>
<video loop controls
preload=\"auto\"
width=\"800px\" 
id=\"video\" 
class=\"b-lazy vjs-big-play-centered vjs-sublime-skin video-js\" 
data-setup=\"{}\" >

<source src=\"". $dir . "/" . $file ."\" type=\"video/webm\">
<p class=\"vjs-no-js\">
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href=\"http://videojs.com/html5-video-support/\" target=\"_blank\">supports HTML5 webm video</a>
</p>
</video>
</div>
<div class=\"video-footer\">
<a class=\"float-left\" href=\"". $dir . "/" . $file ."\">Download</a>
<a class=\"float-left\" href=\"". $dir . "/" . $file ."\">Share</a>
<a class=\"float-right\" href=\"contact.php?title=report&file=" . $file ."\">Report</a>
<a class=\"float-right\" href=\"Thread-" . $file ."\>Comment</a>
</div>

<br/>";         
   }
  }
 }
?>

决定放弃它并在我的项目中使用它

http://pastebin.com/raw/KXMwWicf

然后我将其添加到我的索引

<?php
$dir = isset($_GET['cat']) ? $_GET['cat'] : 'straight';
define('NUMBER_PER_PAGE', 30); 
define('PATH_TO_DIR', $dir); 
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1; 
$list = new PaginateDirectory(PATH_TO_DIR, $page); 
?> 

<td><?php echo $list->displayCount(); ?></td> 
<div class="pagination"><?php echo $list->displayLinks(); ?></div>
<?php foreach( $list->getImages() as $index => $image ){ ?> 
<?php 
$file = basename($image['file']);
print 'whatever'.$file.'whatever';
?>

不知道原始文件归功于谁。