0

I am trying to do what I thought would be simple but is turning into a real headache. Currently we have classic ASP pages that read all the files in a directory and output those to a webpage sorted by date. I have tried several different methods and have been able to get the files and dates and output them to the page but so far I have had no success in getting the records sorted. Here is my current version:

$files = scandir($dir);
foreach($files as $file){
    if($file != "." && $file != ".."){
        if (!is_dir("myFolder/$file")){
            echo $file . "<br />";
            echo date("d-m-Y", filemtime($dir. "\\" . $file)) . "<br />";
        }
    }
}

Normally I was using a 2D array and storing the filename in one field and modified date in the other but with the method I believe it is just storing the data of the file and I can read the result from that field. I have no specific reason for doing it one way or the other. I haven't been able to get either to work.

David M
  • 43
  • 3
  • 10
  • So you want to get all files from a directory sorted by the last modification ? (Also with sub folders?) Also please add a little example how the expected output should look like – Rizier123 Apr 02 '15 at 19:00
  • 1
    Make sure you look at the 2nd solution rather than the accepted answer on that question. – Peter Bowers Apr 02 '15 at 19:09
  • That one solved my problem. I had looked at it previously but tried the selected answer instead of the second one using glob(). Thank you all very much. – David M Apr 02 '15 at 19:25

0 Answers0