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

Number Format...

Format a number with grouped thousands......

Parse a string into separate words...

Parse a string into separate words (array output). function parser($str, $char = ' ') { $str = trim($str); $str = $str . $char; $len = strlen($str); $words = array(); $w = '...

Better parse_str in php...

parse_str() is fine for simple stuff but it's not the same as PHP's built way of creating the $_GET magic variable. Why?!?......

alphaID - Translates a number to a short alhanumeric version...

Translates a number to a short alhanumeric version. e.g.: 9007199254740989 --> PpQXn7COf In most cases this is better than totally random ID generators because this can easily avoid duplicate ID's. Fo...