note 37767 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 19:06:16 +0000
Subject: note 37767 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126547@lists.php.net to get a copy of this message
Note Submitter: Steve Main ---- This will allow you to print out a total recursive directory listing no files just directories for possible tree menues that need folder lists. <?php $DirectoriesToScan = array(realpath('/var/www/axim.caspan.com/Software/')); $DirectoriesScanned = array(); while (count($DirectoriesToScan) > 0) { foreach ($DirectoriesToScan as $DirectoryKey => $startingdir) { if ($dir = @opendir($startingdir)) { while (($file = readdir($dir)) !== false) { if (($file != '.') && ($file != '..')) { $RealPathName = realpath($startingdir.'/'.$file); if (is_dir($RealPathName)) { if (!in_array($RealPathName, $DirectoriesScanned) && !in_array($RealPathName, $DirectoriesToScan)) { $DirectoriesToScan[] = $RealPathName; $DirList[] = $RealPathName; } } } } closedir($dir); } $DirectoriesScanned[] = $startingdir; unset($DirectoriesToScan[$DirectoryKey]); } } $DirList = array_unique($DirList); sort($DirList); foreach ($DirList as $dirname) { echo $dirname."<br>"; } ?>

« previous php.notes (#126547) next »