Can I ask for a certain code on how to generate a random letters and numbers in one word. I know there\'s a PHP function rand(), but I don\'t know if it\'s also applicable w
This will create random alpha num string based on variable chars:
function createRandomCode()
{
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double) microtime() * 1000000);
$i = 0;
$pass = '';
while ($i <= 7)
{
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
Use this function as $random = createRandomCode();
What about this simple code. This will generate 10 characters,you can limit characters by modifying the limits (0,10)
$str = substr(md5(time()), 0, 10);
echo $str; //7aca159655
this one easy
echo strtr(substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789.11.12.13.14.15.16.17.18.19.20'),1,20),array("."=>""));