PHP code example of hedronium / generator-nest

1. Go to this page and download the library: Download hedronium/generator-nest 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/ */

    

hedronium / generator-nest example snippets


function combinations($letters = [])
{
	$chars = ['a', 'b', 'c'];

	foreach ($chars as $char) {
		$merged = array_merge($letters, [$char]);

		yield implode('', $merged);

		if (count($letters) < 2) {
			yield combinations($merged);
		}
	}
}

foreach (combinations() as $combination) {
	// your code
}

use Hedronium\GeneratorNest\GeneratorNest;

foreach (GeneratorNest::nested(combinations()) as $combination) {
	echo $combination, ' ';
}