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

search for in the

iterator_count> <class_parents
Last updated: Fri, 14 Aug 2009

view this page in

iterator_apply

(PHP 5 >= 5.1.0)

iterator_applyApplique une fonction utilisateur à tous les éléments d'un itérateur

Description

int iterator_apply ( Traversable $iterator , callback $function [, array $args ] )

Appelle une fonction pour chaque élément d'un itérateur.

Liste de paramètres

iterator

La classe à passer en revue.

function

La fonction à appeler à chaque élément.

args

Les arguments à passer à la fonction de rappel.

Valeurs de retour

Retourne le nombre d'itération.

Voir aussi

  • array_walk() - Exécute une fonction sur chacun des éléments d'un tableau



add a note add a note User Contributed Notes
iterator_apply
kminkler at synacor dot com
02-Jun-2009 02:02
To clarify, this method does not work exactly like array_walk(), since the current key/value of the iterator is not passed to the callback function.

This php method is equivalent to:

<?php

function iterator_apply(Traversable $iterator, $function, array $args)
{
   
$count = 0;
    foreach (
$iterator as $ignored)
    {
       
call_user_func_array($function, $args);
       
$count++;
    }

    return
$count;
}

?>

iterator_count> <class_parents
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites