Random string are often used in web application to assign records a unique random key. Here is very useful random string generator function that allows you generate random string of any length. Just call the function and pass a length. If you omit length parameter it will generate a 10 characters long alphanumeric string.Random string generator
Last modified
function generate_string($length=10){
$chars = array_merge(range(0, 9), range('A', 'Z'), range('A', 'Z'));
shuffle($chars);
$string = implode(array_slice($chars, 0, $length));
return $string;
}
5 min read