xref: /PHP-5.6/ext/spl/examples/directorytree.php (revision 2e8b9c00)
1<?php
2
3/** @file   directorytree.php
4 * @brief   Program Directory tree example
5 * @ingroup Examples
6 * @author  Marcus Boerger
7 * @date    2003 - 2005
8 *
9 * Usage: php directorytree.php \<path\> [\<start\> [\<count\>]]
10 *
11 * Simply specify the path to tree with parameter \<path\>.
12 */
13
14if ($argc < 2) {
15	echo <<<EOF
16Usage: php ${_SERVER['PHP_SELF']} <path>
17
18Displays a graphical directory tree for the given <path>.
19
20<path> The directory for which to generate the directory tree graph.
21
22
23EOF;
24	exit(1);
25}
26
27if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
28
29$length = $argc > 3 ? $argv[3] : -1;
30
31echo $argv[1]."\n";
32foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $key=>$file) {
33//foreach(new DirectoryTreeIterator($argv[1]) as $file) {
34	echo $file . "\n";
35}
36
37?>