iterator_apply

PHP 5 >= 5.1.0, PHP 7, PHP 8
iterator_apply - Call a function for every element in an iterator
Manual
Code Examples

iterator_apply( Traversable$iterator, callable$callback, [array|null$args = null] ): int

Calls a function for every element in an iterator.

Parameters

iterator

The iterator object to iterate over.

callback

The callback function to call on every element. This function only receives the given args, so it is nullary by default. If count($args) === 3, for instance, the callback function is ternary.

Note:

The function must return true in order to continue iterating over the iterator.

args

An array of arguments; each element of args is passed to the callback callback as separate argument.

Return Values

Returns the iteration count.

Related Functions

Example of iterator_apply

Show all examples for iterator_apply

PHP Version:


Function iterator_apply:

Standard PHP Library (SPL) Functions

Most used PHP functions