Created
September 12, 2014 18:57
-
-
Save brunoaugusto/2e723e35b8d95402acfa 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