Jump to content

[SOLVED] Look into folder, and get latest files added


jjmusicpro

Recommended Posts

Not tested but something liek the following should go pretty close.

 

<?php

$files = array();

// grab all files within the /images directory
foreach (glob("/images/*") as $file) {
    // place them into an array using modification times as key.
    $files[filemtime($file)] = $file;
}

// sort array keys from newest to oldest
arsort($files);

// display 10 latest files.
$i = 1;
foreach ($files as $filemtime => $file) {
    echo $file . "<br />";
    $i++;
    if ($i == 10) {
        break;
    }   
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.