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_apply
(PHP 5 >= 5.1.0)
iterator_apply — Applique une fonction utilisateur à tous les éléments d'un itérateur
Description
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.
iterator_apply
kminkler at synacor dot com
02-Jun-2009 02:02
02-Jun-2009 02:02
