PHP code example of wmde / traversable-iterator

1. Go to this page and download the library: Download wmde/traversable-iterator 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/ */

    

wmde / traversable-iterator example snippets


$iteratorAggregate = new class() implements \IteratorAggregate {
	public function getIterator() {
		yield 'a';
		yield 'b';
		yield 'c';
	}
}

$iterator = new IteratorIterator( $iteratorAggregate );

foreach ( $iterator as $value ) {}
foreach ( $iterator as $value ) {} // Exception: Cannot rewind a generator that was already run