1
即時通訊目前在輸出目錄中保存的所有文本文件:PHP執行opendir排序
$directory = "polls/";
$dir = opendir($directory);
while (($file = readdir($dir)) !== false) {
$filename = $directory . $file;
$type = filetype($filename);
if ($type == 'file') {
$contents = file_get_contents($filename);
list($tag, $name, $description, $text1, $text2, $text3, $date) = explode('¬', $contents);
echo '<table width="500" border="1" cellpadding="4">';
echo "<tr><td>$tag</td></tr>\n";
echo "<tr><td>$name</td></tr>\n";
echo "<tr><td>$description</td></tr>\n";
echo "<tr><td>$text1</td></tr>\n";
echo "<tr><td>$text2</td></tr>\n";
echo "<tr><td>$text3</td></tr>\n";
echo "<tr><td>$date</td></tr>\n";
echo '</table>';
}
}
closedir($dir);
我想延長這種從而使文件輸出之前排序的時候,unixtime格式檔案名稱,以便aphabetically應該這樣做。然後我只想輸出排序後的前5個。這應該給我最新的5.
是否有可能您可以告訴我一個如何實現這個目標的例子? – CLiown