当前位置: 动力学知识库 > 问答 > 编程问答 >

html - Printing Files in Reverse Order PHP

问题描述:

How can I print the files of a directory in reverse aplhabetical order? This is what I'm currently using:

foreach (glob("edit/news/*.txt") as $filename)

{

include $filename;

}

The files are being printed in date-posted order, so the files are named like this:

20111214210118.txt

2011 12 14 21 01 18

Year, Month, Day, Hour, Minute, Second

网友答案:

Pretty sure rsort is what you are looking for.

$files = glob("edit/news/*.txt");
rsort($files);
foreach($files as $filename) {
    include $filename;
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: