Hi there! Today I created by own version in generating random code in PHP from characters A-Z, a-z and 0-9. You can set how many characters to display by setting it in the variable $limit.
PHP Code
<?php
$string="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
//62 is the length of the string. You can check the length of a string using
//strlen($string) function
$limit=10;
$i=0;
$code="";
while($i<$limit)
{
$rand=rand(0,62);
$code=$code.$string[$rand];
$i++;
}
echo $code;
?>
The code above will return 10 random characters from the $string and will generate something like the output below.
Sample Output
fBicU0qbbG / m8I3h7FEjU
0 comments:
Post a Comment