- array_merge: documentation ( source)
- array_rand: documentation ( source)
- range: documentation ( source)
<?php
echo random_code(10) ;
function random_code($length)
{
//This function will get you a randon code. The length will be based on "$length"
$keys = array_merge(range(0,9), range('a', 'z'));
for($i=0; $i < $length; $i++)
{
$key .= $keys[array_rand($keys)];
}
return $key;
}
?>