PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

iterator_to_array> <class_parents
Last updated: Fri, 20 Jun 2008

view this page in

iterator_count

(PHP 5 >= 5.1.3)

iterator_count — Compte de nombre d'éléments dans un itérateur

Description

int iterator_count ( IteratorAggregate $iterator )
Avertissement

Cette fonction n'est pas documentée et seule la liste des arguments est disponible.

Compte les éléments dans un itérateur.

Liste de paramètres

iterator

L'itérateur à compter.

Valeurs de retour

Le nombre d'éléments dans l'itérateur iterator .



add a note add a note User Contributed Notes
iterator_count
Micha Mech
09-May-2008 03:38
Yes, but ...

Traversable: "Abstract base interface that cannot be implemented alone. Instead it must be implemented by either IteratorAggregate or Iterator."

So You have to implement IteratorAggregate or Iterator because You can not implement Traversable.
Ard
31-Aug-2006 03:39
Note that you that the iterator parameter doesn't need to be of type Aggregate. As the spl documentation on http://www.php.net/~helly/php/ext/spl/ defines it in the following way:

    iterator_count (Traversable $it).

So you can count the number of files in a given directory quite easily:
<?php iterator_count(new DirectoryIterator('path/to/dir/'));    ?>

iterator_to_array> <class_parents
Last updated: Fri, 20 Jun 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites