Sort Image with latest modified on top

46 views Asked by At

I am using the following code from Timthumb to built an thumb gallery on my page from a directory. However, I would like to have my image sort so that the latest image is on top. I've try to implement some codes I found on this website, but with no luck. Can anyone help? You can ignore all the stuff with regex.

   <?php
    $images = scandir($dirname);
    $ignore = Array(".", "..", ".DS_Store", "index.php");
    foreach($images as $curimg){
        if(!in_array($curimg, $ignore)) {
            echo "<li><img src=\"img.php?src=$dirname$curimg&w=500&zc=1&q=50\" alt='' style=\"width:100%;\" /></li>\n ";
        }
    }               
?>
0

There are 0 answers