iterator_count
Count the elements in an iterator
&reftitle.description;
intiterator_count
Traversablearrayiterator
Count the elements in an iterator.
iterator_count is not guaranteed to retain the current
position of the iterator.
&reftitle.parameters;
iterator
The iterator being counted.
&reftitle.returnvalues;
The number of elements in iterator.
&reftitle.changelog;
&Version;
&Description;
8.2.0
The type of iterator has been widened from
Traversable to
Traversablearray.
&reftitle.examples;
iterator_count example
'pancakes', 'egg', 'milk', 'flour'));
var_dump(iterator_count($iterator));
?>
]]>
&example.outputs;
iterator_count modifies position
current());
var_dump(iterator_count($iterator));
var_dump($iterator->current());
?>
]]>
&example.outputs;
iterator_count in &foreach; loops
$value) {
echo "$key: $value (", iterator_count($iterator), ")\n";
}?>
]]>
&example.outputs;