jjmusicpro Posted July 23, 2008 Share Posted July 23, 2008 Hi, im not sure if php can do this, but i wanted to look at specific folder like /images/ and have it grab the last 10 that were added in there, is this possible? I then wanted to display them out on my page. Quote Link to comment Share on other sites More sharing options...
trq Posted July 23, 2008 Share Posted July 23, 2008 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; } } ?> Quote Link to comment Share on other sites More sharing options...
jjmusicpro Posted July 23, 2008 Author Share Posted July 23, 2008 how do i make it so it displays the file? Then a box underneith with a copy and paste imge tag with html. Quote Link to comment Share on other sites More sharing options...
jjmusicpro Posted July 23, 2008 Author Share Posted July 23, 2008 i figured it out thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.