Skip to content

Instantly share code, notes, and snippets.

@copperwall
Created May 17, 2017 02:18
Show Gist options
  • Save copperwall/359499e227d1481e079565935b746fb8 to your computer and use it in GitHub Desktop.
Save copperwall/359499e227d1481e079565935b746fb8 to your computer and use it in GitHub Desktop.
Super Simple Generator
<?php
function simpleGenerator() {
yield 1;
yield 2;
}
foreach(simpleGenerator() as $val) {
echo "$val\n";
}
// 1
// 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment