1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

list files by date?

Discussion in 'PHP' started by izlik, Feb 24, 2009.

  1. #1
    Hello. i have a folder full with .jpeg files that has the date format "20070912.jpeg" etc all the way to "20090219.jpeg" and i was wondering if it is possible to list all these from newest to oldest somehow ?
     
    izlik, Feb 24, 2009 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Sort functions will do this just fine.

    $files = glob('*.jpeg');
    rsort($files);
    PHP:
     
    Danltn, Feb 24, 2009 IP
  3. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Hey there. Could you give me an example of how to get an output list for my images from that Sort function? im a litte new to this sorry :/

    PS: i forgot to mention that what im looking to do is to get a noutput of the images on my page listed in the order newest to oldest so that people cann click a link to look at each one of them
     
    izlik, Feb 24, 2009 IP
  4. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    foreach($files as $file) { echo '<img src="' . $file . '" /><br />'; }
    PHP:
     
    Danltn, Feb 24, 2009 IP
    izlik likes this.
  5. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #5
    thank you a lot!, added rep as thanks ^_^
     
    izlik, Feb 24, 2009 IP
  6. tailender1

    tailender1 Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    you can sort them using sort function
    sort($arrayofjpeg) then print them as desired.
     
    tailender1, Feb 25, 2009 IP