Simple PHP script that lists all files in a directory, sorts them by modification date, and creates hyperlinks for each


echo '<html>';

$ignore = array('.', '..', 'index.php');
$files = array();

foreach (scandir($dir) as $file) {
  if (in_array($file, $ignore)) {
  $files[$file] = filemtime($dir . '/' . $file);


$keys = array_keys($files);

foreach ($files as $key => $value) {
  echo date('r', $value), ' <a href="', $dir, '/', $key, '">', $key, '</a><br/>';

echo 'Done';

echo '</html>';

This post is also available in: Greek

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.