Skip to content

Instantly share code, notes, and snippets.


calevans/gist:5fa6d316c2c326a181c1 Secret

Last active Dec 31, 2015
What would you like to do?
$it = null;
$dwarves = [1=>'Grumpy',2=>'Happy',3=>'Sleepy', 4=>'Bashful', 5=>'Sneezy', 6=>'Dopey', 7=>'Doc'];
$it = new CachingIterator(new ArrayIterator($dwarves), CachingIterator::FULL_CACHE);
foreach($it as $v);
foreach($it as $offset=>$value) {
echo 'Original: '.$offset.' == '.$value."\n";
foreach($it->getCache() as $offset=>$value) {
echo 'Cache: '.$offset.' == '.$value."\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment