970_90

Monday, 30 September 2013

iterator_apply - Call a function for every element in an iterator - PHP

int iterator_apply ( Traversable $iterator , callable $function [, array $args ] )
Call a function for every element in an iterator
Calls a function for every element in an iterator.

<?php

function print_caps(Iterator $iterator) {
    echo 
strtoupper($iterator->current()) . "\n";
    return 
TRUE;
}
$it = new ArrayIterator(array("Apples""Bananas""Cherries"));iterator_apply($it"print_caps", array($it));?>


The iterator_apply Function in PHP

No comments:

Post a Comment