Friday, March 28, 2014

Generate random letter in php

Use the following PHP code to generate a random letters.

<?php 
for($i=0;$i<5;$i++) 
    $let[$i] = randLetter(); 
function randLetter()
{
    $int = rand(0,51);
    $a_z = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $rand_letter = $a_z[$int];
    return $rand_letter;
}
$word = implode('',$let);
echo $word;
?>

No comments:

Post a Comment