php-src/ext/spl/examples/tree.php

40 lines
978 B
PHP
Raw Normal View History

2003-07-16 18:47:26 +00:00
<?php
/** @file tree.php
* @brief Program Tree view example
* @ingroup Examples
* @author Marcus Boerger
2005-02-08 19:10:06 +00:00
* @date 2003 - 2005
2003-07-16 18:47:26 +00:00
*
* Usage: php tree.php \<path\>
2003-07-16 18:47:26 +00:00
*
* Simply specify the path to tree with parameter \<path\>.
2003-07-16 18:47:26 +00:00
*/
2003-12-04 19:39:46 +00:00
// The following line only operates on classes which are converted to c already.
// But does not generate a graphical output.
//foreach(new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($argv[1])), 1) as $file) {
if ($argc < 2) {
echo <<<EOF
Usage: php ${_SERVER['PHP_SELF']} <path>
Displays a graphical tree for the given <path>.
<path> The directory for which to generate the tree graph.
EOF;
exit(1);
}
if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
2004-11-01 22:31:11 +00:00
if (!class_exists("DirectoryGraphIterator", false)) require_once("directorygraphiterator.inc");
2003-12-13 14:40:06 +00:00
echo $argv[1]."\n";
2004-11-01 22:31:11 +00:00
foreach(new DirectoryGraphIterator($argv[1]) as $file)
{
2003-11-22 20:51:15 +00:00
echo $file . "\n";
2003-07-16 18:47:26 +00:00
}
?>