3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen_token() { $chars = array_merge(range("z","a"), range("Z", "A"), range("0", "9")); //Define the array length here so we dont have to call count() on each iteration $chars_len = count($chars)-1; $token_len = 25; $token = ""; for($i = 0; $i<$token_len; $i++) { $token .= $chars[mt_rand(0, $chars_len)]; } return $token;; } print strlen(gen_token()) == 25; ?>

preferences:
41.57 ms | 402 KiB | 5 Q