PHP 8.1.0 Alpha 1 available for testing

Класс RecursiveTreeIterator

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

Введение

Позволяет производить итерации по RecursiveIterator для генерации графического дерева в ASCII.

Обзор классов

RecursiveTreeIterator extends RecursiveIteratorIterator implements OuterIterator {
/* Наследуемые константы */
/* Константы */
const int BYPASS_CURRENT = 4 ;
const int BYPASS_KEY = 8 ;
const int PREFIX_LEFT = 0 ;
const int PREFIX_MID_HAS_NEXT = 1 ;
const int PREFIX_MID_LAST = 2 ;
const int PREFIX_END_HAS_NEXT = 3 ;
const int PREFIX_END_LAST = 4 ;
const int PREFIX_RIGHT = 5 ;
/* Методы */
public beginChildren(): void
public callHasChildren(): bool
public __construct(
    RecursiveIterator|IteratorAggregate $it,
    int $flags = RecursiveTreeIterator::BYPASS_KEY,
    int $cit_flags = CachingIterator::CATCH_GET_CHILD,
    int $mode = RecursiveIteratorIterator::SELF_FIRST
)
public current(): string
public endChildren(): void
public endIteration(): void
public getEntry(): string
public getPostfix(): string
public getPrefix(): string
public key(): string
public next(): void
public nextElement(): void
public rewind(): void
public setPostfix(string $postfix): void
public setPrefixPart(int $part, string $value): void
public valid(): bool
/* Наследуемые методы */
public RecursiveIteratorIterator::__construct(Traversable $iterator, int $mode = RecursiveIteratorIterator::LEAVES_ONLY, int $flags = 0)
public RecursiveIteratorIterator::setMaxDepth(int $max_depth = -1): void
}

Предопределённые константы

RecursiveTreeIterator::BYPASS_CURRENT

RecursiveTreeIterator::BYPASS_KEY

RecursiveTreeIterator::PREFIX_LEFT

RecursiveTreeIterator::PREFIX_MID_HAS_NEXT

RecursiveTreeIterator::PREFIX_MID_LAST

RecursiveTreeIterator::PREFIX_END_HAS_NEXT

RecursiveTreeIterator::PREFIX_END_LAST

RecursiveTreeIterator::PREFIX_RIGHT

Содержание

add a note add a note

User Contributed Notes 1 note

up
15
matthieu88160
4 years ago
$it = new RecursiveArrayIterator(array(1, 2, array(3, 4, array(5, 6, 7), 8), 9, 10));
$tit = new RecursiveTreeIterator($it);

foreach( $tit as $key => $value ){
    echo $value . PHP_EOL;
}

/* Will output

|-1
|-2
|-Array
| |-3
| |-4
| |-Array
| | |-5
| | |-6
| | \-7
| \-8
|-9
\-10

*/
To Top