1

我有一个看起来像这样的目录:

/test/
  |
  |- index.php
  |- test-20110324
  |- test-20090901
  |- test-20070901

我想做的是使用“index.php”找到最新的文件,并将require其放入“index.php”文件中。

请注意:包含的文件需要通过日期戳后缀来选择,而不是文件修改时间,因为我需要就地编辑这些旧文件,而不优先于最新的文件。

这个概念将应用于多个目录,但 HTML 文件都将遵循上述模式,即WORD-YYYYMMDD

关于如何做到这一点的任何想法?如果有人能抽出时间来帮助我,我将不胜感激!!!

提前致谢!

4

1 回答 1

3

不应该太难:

$files = glob('*.*'); // change the filemask as you like, prepend a path, etc.
sort($files);         // can be customized with usort if default sort isn't satisfactory
$newest = array_pop($files); // get the last element ("greatest" after sorting);
echo $newest;
于 2011-03-24T21:36:43.293 回答