Skip to content

Instantly share code, notes, and snippets.

@andkirby
Last active July 22, 2016 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andkirby/65c36c14cf1dfe796a967a8877d5f7e4 to your computer and use it in GitHub Desktop.
Save andkirby/65c36c14cf1dfe796a967a8877d5f7e4 to your computer and use it in GitHub Desktop.
$a = new ArrayIterator;
$a->append(++$cnt);
$a->append(++$cnt);
foreach ($a as $i => $item) {
$cnt < 5 && $a->append(++$cnt);
var_dump($item);
}
//int(1)
//int(2)
//int(3)
//int(4)
//int(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment