¡@

Home 

php Programming Glossary: cachingiterator

Peek ahead when iterating an array in PHP

http://stackoverflow.com/questions/2458099/peek-ahead-when-iterating-an-array-in-php

spl share improve this question You can use the CachingIterator for this purpose. Here is an example collection new CachingIterator.. for this purpose. Here is an example collection new CachingIterator new ArrayIterator array 'Cat' 'Dog' 'Elephant' 'Tiger' 'Shark'.. array 'Cat' 'Dog' 'Elephant' 'Tiger' 'Shark' The CachingIterator is always one step behind the inner iterator var_dump collection..

in foreach, isLastItem() exists?

http://stackoverflow.com/questions/4943719/in-foreach-islastitem-exists

You can use a combination of SPL ™s ArrayIterator and CachingIterator class to have a hasNext method iter new CachingIterator new.. CachingIterator class to have a hasNext method iter new CachingIterator new ArrayIterator arr foreach iter as value last_iteration iter..