Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?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(); } ?>
Copy Clear