1
オンラインで見つかったソースに基づいていますが、作成/変更日付で動画を並べ替える必要があります。私はいくつかの解決策を試しましたが、私が本当に満足しているものを見つけたり、思い付いたりすることはできません。誰かが私を正しい方向に向けることができたら大変感謝します。PHP Readdir作成日順に並べ替え
<?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://stackoverflow.com/questions/7642191/php-directory-sort-files-by-date – nogad
これは可能性もありますが、これを行う方法ではなく、オープン/ scandir()? – CucksAreCute
DirectoryIteratorははるかに強力ですが、なぜそれを使用したくないのかわかりません。 – nogad