class RecursiveIteratorIterator implements OuterIterator (View source)

Can be used to iterate through recursive iterators.

Constants

LEAVES_ONLY

The default. Lists only leaves in iteration.

SELF_FIRST

Lists leaves and parents in iteration with parents coming first.

CHILD_FIRST

Lists leaves and parents in iteration with leaves coming first.

CATCH_GET_CHILD

Special flag: Ignore exceptions thrown in accessing children.

Methods

__construct(Traversable $iterator, int $mode = self::LEAVES_ONLY, int $flags = 0)

Construct a RecursiveIteratorIterator

void
rewind()

Rewind the iterator to the first element of the top level inner iterator

bool
valid()

Check whether the current position is valid

mixed
key()

Access the current key

mixed
current()

Access the current element value

void
next()

Move forward to the next element

int
getDepth()

Get the current depth of the recursive iteration

getSubIterator(int $level)

The current active sub iterator

Iterator|null
getInnerIterator()

Get inner iterator

void
beginIteration()

Begin Iteration

void
endIteration()

End Iteration

bool
callHasChildren()

Has children

callGetChildren()

Get children

void
beginChildren()

Begin children

void
endChildren()

End children

void
nextElement()

Next element

void
setMaxDepth(int $maxDepth = -1)

Set max depth

int|false
getMaxDepth()

Get max depth

Details

__construct(Traversable $iterator, int $mode = self::LEAVES_ONLY, int $flags = 0)

Since: 5.1.3

Construct a RecursiveIteratorIterator

Parameters

Traversable $iterator
int $mode

[optional] The operation mode. See class constants for details.

int $flags

[optional] A bitmask of special flags. See class constants for details.

void rewind()

Rewind the iterator to the first element of the top level inner iterator

Return Value

void

Any returned value is ignored.

bool valid()

Check whether the current position is valid

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

mixed key()

Access the current key

Return Value

mixed

TKey on success, or null on failure.

mixed current()

Access the current element value

Return Value

mixed

Can return any type.

void next()

Move forward to the next element

Return Value

void

Any returned value is ignored.

int getDepth()

Get the current depth of the recursive iteration

Return Value

int

The current depth of the recursive iteration.

RecursiveIterator|null getSubIterator(int $level)

The current active sub iterator

Parameters

int $level [optional]

Return Value

RecursiveIterator|null

The current active sub iterator.

Iterator|null getInnerIterator()

Get inner iterator

Return Value

Iterator|null

The inner iterator for the current entry.

void beginIteration()

Begin Iteration

Return Value

void

void endIteration()

End Iteration

Return Value

void

bool callHasChildren()

Has children

Return Value

bool

true if the element has children, otherwise false

RecursiveIterator|null callGetChildren()

Get children

Return Value

RecursiveIterator|null

A RecursiveIterator.

void beginChildren()

Begin children

Return Value

void

void endChildren()

End children

Return Value

void

void nextElement()

Next element

Return Value

void

void setMaxDepth(int $maxDepth = -1)

Set max depth

Parameters

int $maxDepth

[optional]

The maximum allowed depth. Default -1 is used for any depth.

Return Value

void

int|false getMaxDepth()

Get max depth

Return Value

int|false

The maximum accepted depth, or false if any depth is allowed.