3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(-1); set_time_limit(0); generate_nice('php'); 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 = ''; srand($i); for ($j = 0; $j < $l; ++$j) { $s .= chr(96 + rand(1, 26)); } } return $i - 1; } function test($i, $l) { $s = ''; srand($i); for ($j = 0; $j < $l; ++$j) { $s .= chr(96 + rand(1, 26)); } return $s; }
Output for 7.1.0
Word: php Seed: 7736 Test: php
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
Word: php Seed: 10891 Test: php