Since: 5.4

class RecursiveCallbackFilterIterator extends CallbackFilterIterator implements RecursiveIterator (View source)

(PHP 5 >= 5.4.0)
RecursiveCallbackFilterIterator from a RecursiveIterator

Methods

__construct(Traversable $iterator, callable $callback)

Create a RecursiveCallbackFilterIterator from a RecursiveIterator

Iterator|null
getInnerIterator()

Get the inner iterator

void
rewind()

Rewind the iterator

bool
valid()

Check whether the current element is valid

mixed
key()

Get the current key

mixed
current()

Get the current element value

void
next()

Move the iterator forward

bool
accept()

This method calls the callback with the current value, current key and the inner iterator.

bool
hasChildren()

Check whether the inner iterator's current element has children

getChildren()

Returns an iterator for the current entry.

Details

__construct(Traversable $iterator, callable $callback)

Create a RecursiveCallbackFilterIterator from a RecursiveIterator

Parameters

Traversable $iterator
callable $callback

The callback, which should return TRUE to accept the current item or FALSE otherwise. May be any valid callable value. The callback should accept up to three arguments: the current item, the current key and the iterator, respectively. function my_callback($current, $key, $iterator)

Iterator|null getInnerIterator()

Get the inner iterator

Return Value

Iterator|null

The inner iterator for the current entry.

void rewind()

Rewind the iterator

Return Value

void

Any returned value is ignored.

bool valid()

Check whether the current element 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()

Get the current key

Return Value

mixed

TKey on success, or null on failure.

mixed current()

Get the current element value

Return Value

mixed

Can return any type.

void next()

Move the iterator forward

Return Value

void

Any returned value is ignored.

bool accept()

This method calls the callback with the current value, current key and the inner iterator.

The callback is expected to return TRUE if the current item is to be accepted, or FALSE otherwise.

Return Value

bool

true if the current element is acceptable, otherwise false.

bool hasChildren()

Check whether the inner iterator's current element has children

Return Value

bool

true if the current entry can be iterated over, otherwise returns false.

RecursiveIterator|null getChildren()

Returns an iterator for the current entry.

Return Value

RecursiveIterator|null

An iterator for the current entry.