SPL-StandardPHPLibrary
tree.php
Go to the documentation of this file.
1 <?php
2 
14 // The following line only operates on classes which are converted to c already.
15 // But does not generate a graphical output.
16 //foreach(new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($argv[1])), 1) as $file) {
17 
18 if ($argc < 2) {
19  echo <<<EOF
20 Usage: php ${_SERVER['PHP_SELF']} <path>
21 
22 Displays a graphical tree for the given <path>.
23 
24 <path> The directory for which to generate the tree graph.
25 
26 
27 EOF;
28  exit(1);
29 }
30 
31 if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
32 if (!class_exists("DirectoryGraphIterator", false)) require_once("directorygraphiterator.inc");
33 
34 echo $argv[1]."\n";
35 foreach(new DirectoryGraphIterator($argv[1]) as $file)
36 {
37  echo $file . "\n";
38 }
39 
40 ?>
A tree iterator that only shows directories.