La classe RecursiveTreeIterator

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

Introduction

Permet l'itération d'un RecursiveIterator pour générer un arbre graphique ASCII.

Synopsis de la classe

class RecursiveTreeIterator extends RecursiveIteratorIterator {
/* Constantes héritées */
/* Constantes */
public const int BYPASS_CURRENT;
public const int BYPASS_KEY;
public const int PREFIX_LEFT;
public const int PREFIX_MID_HAS_NEXT = 1;
public const int PREFIX_MID_LAST = 2;
public const int PREFIX_END_HAS_NEXT = 3;
public const int PREFIX_END_LAST = 4;
public const int PREFIX_RIGHT = 5;
/* Méthodes */
public __construct(
    RecursiveIterator|IteratorAggregate $iterator,
    int $flags = RecursiveTreeIterator::BYPASS_KEY,
    int $cachingIteratorFlags = CachingIterator::CATCH_GET_CHILD,
    int $mode = RecursiveTreeIterator::SELF_FIRST
)
public current(): mixed
public endChildren(): void
public endIteration(): void
public getEntry(): string
public getPostfix(): string
public getPrefix(): string
public key(): mixed
public next(): void
public nextElement(): void
public rewind(): void
public setPostfix(string $postfix): void
public setPrefixPart(int $part, string $value): void
public valid(): bool
/* Méthodes héritées */
}

Sommaire

add a note

User Contributed Notes 1 note

up
23
matthieu88160
7 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