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 — Apply a user function to every element of an iterator
설명
Calls a function for every element in an iterator.
인수
- iterator
-
The class to walk through.
- function
-
The callback function to call on every element.
- args
-
Arguments to pass to the callback function.
반환값
Returns the iteration count.
iterator_apply
kminkler at synacor dot com
02-Jun-2009 02:02
02-Jun-2009 02:02
