3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Word: hello
Process exited with code 137.