3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateRandomName($minLength, $maxLength, $alphaNumericOnly = false) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; if (!$alphaNumericOnly) $chars .= ' '; $randomString = ''; $length = mt_rand($minLength, $maxLength); for ($i = 0; $i < $length; $i++) { $randomString .= $chars[rand(0, strlen($chars) - 1)]; } return $randomString; } $time = microtime(true); $i=0; while($i < 10000) { $i++; $this->generateRandomName(10, 18); } $time = microtime(true) - $time; echo 'took ' . number_format($time, 3);

preferences:
28.32 ms | 402 KiB | 5 Q