//generates 13 character random unique alphanumeric id
echo uniqid();
//output - 5e6d873a4f597
<?php
$random = substr(md5(mt_rand()), 0, 7);
echo $random;
?>
function rand_str() {
$characters = '0123456789-=+{}[]:;@#~.?/>,<|!"£$%^&*()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomstr = '';
for ($i = 0; $i < random_int(50, 100); $i++) {
$randomstr .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomstr;
}
function generateRandomString($digits) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randstring = '';
for ($i = 0; $i < $digits; $i++) {
$randstring .= $characters[rand(0, strlen($characters))];
}
return $randstring;
}
echo generateRandomString(24);
function RandomString()
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randstring = '';
for ($i = 0; $i < 10; $i++) {
$randstring = $characters[rand(0, strlen($characters))];
}
return $randstring;
}
random_int ( int $min , int $max );
$string = bin2hex(openssl_random_pseudo_bytes(10)); // 20 chars