Skip to content

Instantly share code, notes, and snippets.

@calevans calevans/gist:5fa6d316c2c326a181c1 Secret
Last active Dec 31, 2015

Embed
What would you like to do?
<?php
$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);
$it->offsetUnset(4);
$it->offsetSet('Cal','Kathy');
$it[5]='Surly';
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
You can’t perform that action at this time.