![]() |
VOOZH | about |
The iterator_count() function is an inbuilt function in PHP that is used to count the number of elements in an iterator. An iterator is an object that is a collection of elements.
Syntax:
iterator_count(Traversable $iterator) : int
Parameters: This function accepts only one parameter which is described below.
raversable interface, such as an array or an instance of a class that implements iterator or IteratorAggregate.Return Value: The iterator_count() function returns the number of elements in the iterator if this function successfully executes.
Program 1: The following program demonstrates the iterator_count() function.
Total elements in the iterator: 5
Program 2: The following program demonstrates the iterator_count() function.
Total number of characters in the string: 13
Reference:https://www.php.net/manual/en/function.iterator-count.php