Skip to content

Instantly share code, notes, and snippets.

@tamakiii
Last active October 20, 2015 17:52
Show Gist options
  • Save tamakiii/96a4f2cef678e33fb5f1 to your computer and use it in GitHub Desktop.
Save tamakiii/96a4f2cef678e33fb5f1 to your computer and use it in GitHub Desktop.
<?php
/**
* PHP 5.5.16 (cli) (built: Apr 1 2015 22:23:30)
* Copyright (c) 1997-2014 The PHP Group
* Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
* with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
* with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
*/
function y() {
foreach (range(0, 3) as $value) {
yield $value;
}
}
foreach (y() as $value) {
echo $value . ' ';
}
#=> 0 1 2 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment