- array_reverse: documentation ( source)
- ini_set: documentation ( source)
- range: documentation ( source)
- array_pop: documentation ( source)
<?php
ini_set('error_reporting', -1);
ini_set('display_errors', 'on');
class Foo
{
private static $a;
public function __construct()
{
self::$a = range('A', 'Z');
}
public function generator()
{
while(self::$a) {
yield array_reverse(array_pop(self::$a));
}
}
}
$foo = new Foo;
$generator = $foo->generator();
if ($generator->valid()) {
foreach($generator as $i) {
echo $i;
}
} else {
echo 'Nothing';
}
$generator = $foo->generator();
if ($generator->valid()) {
foreach($generator as $i) {
echo $i;
}
} else {
echo 'Nothing';
}