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

Detect file extension function...

This function is used to find the file extension also you can use pathinfo() function for get information about a file path. function ext($file_name) { return substr($file_name, strrpos($fi...

Best way to get user ip address in php...

Here is a function to getting ip using filter of local and lan ip's. function get_ip() { $list = array( 'REMOTE_ADDR', 'CLIENT_IP', 'HTTP_CLIENT_IP', 'HTTP_PROXY_CONNECTION',...

Change timestamp to custom format...

Use this function for change timestamp to custom format......

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?!?......