Generation of a random number from a simple PHP function :
This is a simple code snippet for randomly generate String containing alphabets & numbers in PHP.
This function can be used anywhere in between the script where you want to generate a random string...
function rand_string($l){
$s= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
for($i=0; $i<$l; $i++) {
$rand.= $s[rand()%strlen($s)];
}
return $rand;
}
No comments:
Post a Comment