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, 24 Jul 2009

view this page in

iterator_apply

(PHP 5 >= 5.1.0)

iterator_applyApply a user function to every element of an iterator

설명

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

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.

참고

  • array_walk() - 배열의 각 원소에 대해서 특정 함수를 적용



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, 24 Jul 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites