You can use RandomPassword function;

<?
function RandomPassword($passlength) {
$chars
“ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
$chars .“1234567890″;
$chars .= “abcdefghijklmnopqrstuvwxyz”;
$charsLength strlen($chars);
for (
$ras 0$ras <$
passlength$ras++) {
$number rand(0,$
charsLength-1);
$password .= $chars[$number];
}
return 
$password;
}
echo $RandomPassword(8);
?>

See demo