note 105192 added to class.dir
| From: | AlexA dot at osu1 dot php dot net | Date: | Tue, 02 Aug 2011 12:27:27 +0000 |
| Subject: | note 105192 added to class.dir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182099@lists.php.net to get a copy of this message | ||
<?PHP
/*Simple, good looking recursive function for printing directories.
Just copy/paste and it is ready to go!*/
function printCurrentDirRecursively($originDirectory, $printDistance=0){
// just a little html-styling
if($printDistance==0)echo '<div style="color:#35a; font-family:Verdana;
font-size:11px;">';
$leftWhiteSpace = "";
for ($i=0; $i < $printDistance; $i++) $leftWhiteSpace = $leftWhiteSpace." ";
$CurrentWorkingDirectory = dir($originDirectory);
while($entry=$CurrentWorkingDirectory->read()){
if($entry != "." && $entry != ".."){
if(is_dir($originDirectory."\\".$entry)){
echo $leftWhiteSpace."<b>".$entry."</b><br>\n";
printCurrentDirRecursively($originDirectory."\\".$entry, $printDistance+2);
}
else{
echo $leftWhiteSpace.$entry."<br>\n";
}
}
}
$CurrentWorkingDirectory->close();
if($printDistance==0)echo "</div>";
}
//TEST IT!
printCurrentDirRecursively(getcwd());
?>
----
Server IP: 69.147.83.197
Probable Submitter: 178.26.4.115
----
Manual Page -- http://www.php.net/manual/en/class.dir.php
Edit -- https://master.php.net/note/edit/105192
Del: integrated -- https://master.php.net/note/delete/105192/integrated
Del: useless -- https://master.php.net/note/delete/105192/useless
Del: bad code -- https://master.php.net/note/delete/105192/bad+code
Del: spam -- https://master.php.net/note/delete/105192/spam
Del: non-english -- https://master.php.net/note/delete/105192/non-english
Del: in docs -- https://master.php.net/note/delete/105192/in+docs
Del: other reasons-- https://master.php.net/note/delete/105192
Reject -- https://master.php.net/note/reject/105192
Search -- https://master.php.net/manage/user-notes.php