Random string generator

Random string generator. Optionally, you can give it a desired string length.

function rnd_string($len = 24)
{
    $str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $strlen = strlen($str) - 1;
    $result = '';
    for ($i = 0; $i < $len; $i++)
        $result .= $str[rand(0, $strlen)];
    return $result;
}
 
echo rnd_string();

Tags

No tag here.

Recommended pages

Download a file from web to local...

Use this function to download a file from web to local machine. function WgetFile( $URL, $dir ) { $nomefile = $dir . "/" . basename( $URL ); if ( copy( $URL, $nomefile ) ) { retu...

Gregorian to Persian Date Convertor...

Gregorian to Persian Date Convertor....

Extract numbers from a unicode string...

Quick extract numbers from a unicode string......

URL Checker...

This function check if an url is valid or not. function is_valid_url($url) { return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); }...