3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createCombinations($input_str, $length) { $input = str_split($input_str); foreach($input as $c) { if($length == 1) { yield $c; return; } else { foreach(createCombinations($input_str, $length -1) as $s) { yield $c + $s; return; } } } } $texte = "abcdefghijklmnopqrstuvwxyz0123456789"; foreach(createCombinations($texte, 4) as $result) { echo $result; }

preferences:
59.11 ms | 402 KiB | 5 Q