Just numbers
1 2 3 |
echo mt_rand (10,1000000); |
and both numbers and letters
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomstring; } echo generateRandomString(); |