note 24856 added to ref.dir

From: Date: Fri, 30 Aug 2002 11:36:04 +0000
Subject: note 24856 added to ref.dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-36032@lists.php.net to get a copy of this message
Small script to list all files + size + date (like the DOS dir command) //define the path as relative $path = "."; //using the opendir function $dir_handle = @opendir($path) or die("Unable to open $path"); //make string with 70 spaces $space=" "; echo "<PRE>"; echo "Directory Listing of $path\n"; //running the while loop while ($file = readdir($dir_handle)) { // filename - output left-justified $t="<a href=$file>$file</a>"; echo $t.substr($space,0,40-strlen($file)) ; // filesize - output right-justified $t=(filesize($file)/1024); $t=sprintf("%01.2f",$t)."kb "; echo substr($space,0,10-strlen($t)) . $t ; // filedate - output left-justified $t=date("d.M Y H:i:s", filemtime($file)); echo $t.substr($space,0,20-strlen($file)) ; echo "\n"; } //closing the directory closedir($dir_handle); echo "</PRE>"; -- http://www.php.net/manual/en/ref.dir.php http://master.php.net/manage/user-notes.php?action=edit+24856 http://master.php.net/manage/user-notes.php?action=delete+24856 http://master.php.net/manage/user-notes.php?action=reject+24856

« previous php.notes (#36032) next »