문제

To show all files from folder i use this.

<?php
    foreach (glob("pardod/*.html") as $filename)
    {
        include $filename;
    }
?>

Yes, its show that what i want but not realy, becouse i need to sort this files to display older to newest.

I found one solutions, but they only works like a echo, but he dont display files like a first code, what is on the top.

$files = glob( 'pardod/*.html' );
array_multisort(
    array_map( 'filemtime', $files ),
    SORT_NUMERIC,
    SORT_DESC,
    $files
);
print_r( $files);

(Sory for my bad english)

도움이 되었습니까?

해결책

Just replace print_r($files) with

foreach ($files as $file) {
    include $file;
}

And you should be fine.

다른 팁

You are looking for something like this:

<?php
$files = array();
$iterator = new DirectoryIterator(dirname(__FILE__));
   foreach ($iterator as $fileinfo) {
   if ($fileinfo->isFile()) {
      $files['name'][] = $fileinfo->getFilename();
      $files['edittime'][] = $fileinfo->getMTime();
   }
  }
  array_multisort($files['edittime'],SORT_DESC, $files['name']);
  foreach ($files as $file) {
    include $file;
  };
 ?>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top