Listing files by "last modified"

Discussion in 'PHP' started by jkashu, Apr 4, 2008.

  1. #1
    I need to list the files in a directory in order of when they were created. Any ideas? I have no problem listing them; the ordering is my issue.

    Thanks!
     
    jkashu, Apr 4, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Hello,

    You can glob() the files, and stat() them to get the access/modified details as you require. From here, store these in an array (i.e. modified-timestamp => filename), and sort the arraying using PHP, and foreach to output it.

    Hope this helps,

    Jay
     
    jayshah, Apr 4, 2008 IP
  3. jkashu

    jkashu Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I just can't get the arrays to work right....arrays in PHP always confuse me...lol....

    Anyway.. does anybody have a snippet of code that lists files by last modified??

    Thanks!
     
    jkashu, Apr 30, 2008 IP