PHP > Directory Functions

Read a directory and output files

 $list_ignore = array
         ('.','..','images','Thumbs.db','index.php','.htaccess','.htpasswd');
 $handle=opendir ('.');
 while (false !== ($file = readdir ($handle))) {
   if (!in_array($file,$list_ignore)) $out[filemtime($file)] =
       $file."</td><td>".date("d.m.Y",filemtime($file));
 }
 closedir($handle);
 if ($out)
 {
  krsort ($out);
  echo "<table border=0>";
  foreach($out as $item) {
	echo "<tr><td><a href=\"$item\">$item</a></td></tr> \n";
  }
 }

Leave a Reply