Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<RecursiveFilterIterator::hasChildrenRecursiveIteratorIterator::beginChildren>
^IteratorsLast updated: Mon, 26 Oct 2026

The RecursiveIteratorIterator class

(PHP 5, PHP 7, PHP 8)

Introduction

Can be used to iterate through recursive iterators.

Calls to methods that RecursiveIteratorIterator does not have are forwarded to the iterator at the current depth, as returned by RecursiveIteratorIterator::getSubIterator(). This does not use __call().

Class synopsis

class RecursiveIteratorIterator implements OuterIterator {
/* Constants */
public const int LEAVES_ONLY;
public const int SELF_FIRST;
public const int CHILD_FIRST;
public const int CATCH_GET_CHILD;
/* Methods */
public function __construct(Traversable $iterator, int $mode = RecursiveIteratorIterator::LEAVES_ONLY, int $flags = 0)
public function beginChildren(): void
public function beginIteration(): void
public function callHasChildren(): bool
public function current(): mixed
public function endChildren(): void
public function endIteration(): void
public function getDepth(): int
public function getMaxDepth(): int|false
public function getSubIterator(?int $level = null): ?RecursiveIterator
public function key(): mixed
public function next(): void
public function nextElement(): void
public function rewind(): void
public function setMaxDepth(int $maxDepth = -1): void
public function valid(): bool
}

Changelog

Version Description
8.4.0 The class constants are now typed.

Table of Contents


<RecursiveFilterIterator::hasChildrenRecursiveIteratorIterator::beginChildren>
^IteratorsLast updated: Mon, 26 Oct 2026