Random letters with PHP

17 March 2009 | Tips & Tricks | Tags:

Since it was no already function for random letters in PHP i was google on it and found this one some where i do not remeber but works exemplary.

function randomletters() {
$chars = “abcdefghijkmnopqrstuvwxyz023456789″;
srand((double)microtime()*1000000);
$i = 0;
$pass = ” ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}

If you know who made this one please tell me and i will link to the page in this post :)

For random numbers please take a look at rand.


Leave a Reply