See the details here
$length = 10;
$key = "";
// define possible characters
$possible = "0123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRTVWXYZ";
$i = 0;
while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
$key .= $char;
$i++;
}
return $key;