3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php define("EOL", "\n"); $max = 40; $start = ord("a"); $limit = ord("y"); $arr = array(); $arr[0] = chr($start); while($max--){ for($i = 0; $i <= (count($arr) - 1); $i++){ if(ord($arr[$i]) > $limit){ $arr[$i] = chr($start); if(isset($arr[$i + 1])){ $arr[$i+1] = chr(ord($arr[$i+1]) + 1); } else { $arr[$i+1] = chr($start); } } } var_dump(array_reverse($arr)); echo "[", implode("][", array_reverse($arr)), "]", EOL; $arr[0]++; }
based on ubWQ6
Output for 5.5.0 - 7.2.0
array(1) { [0]=> string(1) "a" } [a] array(1) { [0]=> string(1) "b" } [b] array(1) { [0]=> string(1) "c" } [c] array(1) { [0]=> string(1) "d" } [d] array(1) { [0]=> string(1) "e" } [e] array(1) { [0]=> string(1) "f" } [f] array(1) { [0]=> string(1) "g" } [g] array(1) { [0]=> string(1) "h" } [h] array(1) { [0]=> string(1) "i" } [i] array(1) { [0]=> string(1) "j" } [j] array(1) { [0]=> string(1) "k" } [k] array(1) { [0]=> string(1) "l" } [l] array(1) { [0]=> string(1) "m" } [m] array(1) { [0]=> string(1) "n" } [n] array(1) { [0]=> string(1) "o" } [o] array(1) { [0]=> string(1) "p" } [p] array(1) { [0]=> string(1) "q" } [q] array(1) { [0]=> string(1) "r" } [r] array(1) { [0]=> string(1) "s" } [s] array(1) { [0]=> string(1) "t" } [t] array(1) { [0]=> string(1) "u" } [u] array(1) { [0]=> string(1) "v" } [v] array(1) { [0]=> string(1) "w" } [w] array(1) { [0]=> string(1) "x" } [x] array(1) { [0]=> string(1) "y" } [y] array(2) { [0]=> string(1) "a" [1]=> string(1) "a" } [a][a] array(2) { [0]=> string(1) "a" [1]=> string(1) "b" } [a][b] array(2) { [0]=> string(1) "a" [1]=> string(1) "c" } [a][c] array(2) { [0]=> string(1) "a" [1]=> string(1) "d" } [a][d] array(2) { [0]=> string(1) "a" [1]=> string(1) "e" } [a][e] array(2) { [0]=> string(1) "a" [1]=> string(1) "f" } [a][f] array(2) { [0]=> string(1) "a" [1]=> string(1) "g" } [a][g] array(2) { [0]=> string(1) "a" [1]=> string(1) "h" } [a][h] array(2) { [0]=> string(1) "a" [1]=> string(1) "i" } [a][i] array(2) { [0]=> string(1) "a" [1]=> string(1) "j" } [a][j] array(2) { [0]=> string(1) "a" [1]=> string(1) "k" } [a][k] array(2) { [0]=> string(1) "a" [1]=> string(1) "l" } [a][l] array(2) { [0]=> string(1) "a" [1]=> string(1) "m" } [a][m] array(2) { [0]=> string(1) "a" [1]=> string(1) "n" } [a][n] array(2) { [0]=> string(1) "a" [1]=> string(1) "o" } [a][o]