Hi, what is the fastest way to generate a random two long alphanumeric character?
Thanks, Max
Hi, what is the fastest way to generate a random two long alphanumeric character?
Thanks, Max
How about
$az = range('a', 'z');
$r = array_rand($az, 2);
$str = $az[$r[0]] . $az[$r[1]];
This would do the job beautifully:
substr(md5(uniqid(microtime(true),true)),0,2);
This technique is used quite often for alphanumeric password salts in databases.
Based on Jani's answer:
join('', array_rand(array_merge(range('a', 'z'), range('0', '9')), 2))
how about this?
base_convert(rand(0,35), 10, 36) . base_convert(rand(0,35), 10, 36)