note 74967 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 18:58:09 +0000
Subject: note 74967 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126490@lists.php.net to get a copy of this message
Note Submitter: aryel at redtwilight dot nospam dot com dot br ---- I've made this function that lists all files and folders recursively using readdir (a good alternative to those without PHP5's directory functions) <?php function DirList($dir) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $link = $dir."/".$file; $i++; if(is_dir($dir."/".$file)) { echo " <br><b>Directory '$link'</b> <table cellpadding=\"1\"> <tr> <td>&nbsp&nbsp;</td> <td>"; DirList($link); echo " </td> </tr> </table>"; continue; } else { echo "<br>&bull; <a href=\"$link\"><b>$link</b></a> - ".filesize($link)." bytes"; } } } if($i <= 0) { echo "-- Folder is empty --"; } closedir($handle); } } // this will list the directory itself DirList("."); ?>

« previous php.notes (#126490) next »