Skip to content

Instantly share code, notes, and snippets.

@hrach
Created March 21, 2013 22:11
Show Gist options
  • Save hrach/5217268 to your computer and use it in GitHub Desktop.
Save hrach/5217268 to your computer and use it in GitHub Desktop.
<?php
class TestIterator implements \IteratorAggregate
{
public function getIterator()
{
return new ArrayIterator(array(1, 2, 3));
}
}
class Test implements \IteratorAggregate
{
public function getIterator()
{
return new TestIterator();
}
}
foreach (new Test as $v) {
echo $v;
}
// 123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment