PHP code example of jeroen / rewindable-generator

1. Go to this page and download the library: Download jeroen/rewindable-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jeroen / rewindable-generator example snippets


$generator = $myGeneratorFunction();
iterator_to_array($generator);
iterator_to_array($generator); // boom!

$generator = $myGeneratorFunction();
$generator->next();
$generator->rewind(); // boom!

$generator = new RewindableGenerator($myGeneratorFunction);
iterator_to_array($generator);
iterator_to_array($generator); // works as expected
$generator->rewind(); // works as expected