CachingIterator::key

(PHP 5, PHP 7, PHP 8)

CachingIterator::key — Return the key for the current element

Description

public function CachingIterator::key(): mixed

Returns the key of the current element.

As the CachingIterator is one element ahead of its inner iterator, this is the key that was stored when the iterator last moved, not the current key of the inner iterator.

Parameters

This function has no parameters.

Return Values

Returns the key of the current element, or null if the iterator is not valid.

See Also