3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); set_time_limit(0); generate_nice('hello'); generate_nice('world'); function generate_nice($word) { echo 'Word: ', $word, "\n"; $i = generate($word); echo 'Seed: ', $i, "\n"; echo 'Test: ', test($i, strlen($word)), "\n"; } function generate($word) { $l = strlen($word); $s = ''; for ($i = 0; $s !== $word; ++$i) { $s = ''; mt_srand($i); for ($j = 0; $j < $l; ++$j) { $s .= chr(96 + mt_rand(1, 26)); } } return $i - 1; } function test($i, $l) { $s = ''; mt_srand($i); for ($j = 0; $j < $l; ++$j) { $s .= chr(96 + mt_rand(1, 26)); } return $s; }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
Word: hello
Process exited with code 137.

preferences:
153.79 ms | 404 KiB | 210 Q