- substr: documentation ( source)
- rand: documentation ( source)
<?php
$alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$length = 11;
for($i=0; $i<$length; $i++){
$ran = rand(0, strlen($alpha)-1);
$key .= substr($alpha, $ran, 1);
}
echo $key;
?>