PHP 8.5.8 Released!

The RecursiveTreeIterator class

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

简介

Allows iterating over a RecursiveIterator to generate an ASCII graphic tree.

类摘要

class RecursiveTreeIterator extends RecursiveIteratorIterator {
/* 继承的常量 */
/* 常量 */
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;
/* 方法 */
public function __construct (
RecursiveIterator |IteratorAggregate $iterator,
int $flags = RecursiveTreeIterator::BYPASS_KEY ,
int $cachingIteratorFlags = CachingIterator::CATCH_GET_CHILD ,
int $mode = RecursiveTreeIterator::SELF_FIRST
)
public function beginChildren (): void
public function beginIteration (): RecursiveIterator
public function callGetChildren (): RecursiveIterator
public function callHasChildren (): bool
public function current (): mixed
public function endChildren (): void
public function endIteration (): void
public function getEntry (): string
public function getPostfix (): string
public function getPrefix (): string
public function key (): mixed
public function next (): void
public function nextElement (): void
public function rewind (): void
public function setPostfix (string $postfix): void
public function setPrefixPart (int $part, string $value): void
public function valid (): bool
/* 继承的方法 */
public function RecursiveIteratorIterator::setMaxDepth (int $maxDepth = -1): void
}

目录

发现了问题?

了解如何改进此页面提交拉取请求报告一个错误
+添加备注

用户贡献的备注 1 note

up
21
matthieu88160
9 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
*/
+添加备注

AltStyle によって変換されたページ (->オリジナル) /