Question : PHP random string generator
Answered by : code-grepper
function generateRandomString($length = 25) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString;
}
//usage
$myRandomString = generateRandomString(5);
Source : | Last Update : Wed, 06 Nov 19
Question : random string generator php
Answered by : ankur-prajapati
<?php function RandomString() { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randstring = ''; for ($i = 0; $i < 10; $i++) { $randstring = $characters[rand(0, strlen($characters))]; } return $randstring; } RandomString(); echo $randstring;
Source : https://stackoverflow.com/questions/4356289/php-random-string-generator | Last Update : Sat, 18 Jul 20