-
-
Save smallsong/cdd3b70f5ea4679190023ae65bb7dbfa to your computer and use it in GitHub Desktop.
Simple script to generate an ASCII graphic tree of given directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$directory = './misc'; | |
try { | |
$iterator = new RecursiveTreeIterator( | |
new RecursiveDirectoryIterator( | |
$directory, RecursiveDirectoryIterator::SKIP_DOTS | |
), | |
RecursiveIteratorIterator::SELF_FIRST | |
); | |
print '<pre>'; | |
foreach( $iterator as $path ) echo str_replace( $directory, '', $path ), "\n"; | |
} catch( UnexpectedValueException $e ) { | |
printf( 'Directory <strong>%s,</strong> cannot be traversed', $directory ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment