mirror of
https://github.com/php/php-src.git
synced 2026-03-29 19:52:20 +02:00
21 lines
476 B
PHP
21 lines
476 B
PHP
<?php
|
|
|
|
class DirectoryTreeIterator extends RecursiveIteratorIterator
|
|
{
|
|
function __construct($path)
|
|
{
|
|
parent::__construct(new CachingRecursiveIterator(new RecursiveDirectoryIterator($path), true), 1);
|
|
}
|
|
|
|
function current()
|
|
{
|
|
$tree = '';
|
|
for ($l=0; $l < $this->getLevel(); $l++) {
|
|
$tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
|
|
}
|
|
return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
|
|
. $this->getSubIterator($l);
|
|
}
|
|
}
|
|
|
|
?>
|