spl - PHP lazy array mapping -


is there way of doing array_map iterator?

for example:

foreach (new mapiterator($array, $function) $value) {    if ($value == $required)       break; } 

the reason $function hard calculate , $array has many elements, need map until find specific value. array_map calculate values before can search 1 want.

i implement iterator myself, want know if there native way of doing this. couldn't find searching php documentation.

in short: no.

there no lazy iterator mapping built php. there non-lazy function iterator_apply(), nothing after.

you write 1 yourself, said. suggest extend iteratoriterator , override current() method.

if there such thing either documented here or here.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -