Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
function Gen()
{
yield 'key' => 'value';
yield 'key2' => 'value2';
yield 'key3' => 'value3';
}
$gen = Gen();
$gen->rewind();
echo "{$gen->key()} => {$gen->current()}";
echo PHP_EOL.PHP_EOL;
// echo $gen->key().' => '.$gen->current();
// echo PHP_EOL.PHP_EOL;
while ( $gen->valid() )
{
echo PHP_EOL;
echo $gen->key().' => '.$gen->current();
echo PHP_EOL;
$gen->next();
}
$gen->rewind();
while ( $gen->valid() )
{
echo PHP_EOL;
echo $gen->key().' => '.$gen->current();
echo PHP_EOL;
$gen->next();
}
?>