public function random_string($length = 32)
    {
        return substr(str_shuffle(str_repeat(
            $x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
            ceil($length / strlen($x))
        )), 1, $length);
    }
public function random_string($length = 32)
    {
        return substr(str_shuffle(str_repeat(
            $x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
            ceil($length / strlen($x))
        )), 1, $length);
    }
public function random_string ( $ length = 32 ) { return substr ( str_shuffle ( str_repeat ( $ x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' , ceil ( $ length / strlen ( $ x ) ) ) ) , 1 , $ length ) ; }
Generates a random string based on given length.

Blatantly taken from StackOverflow: http://stackoverflow.com/a/13212994/1524676

@param int $length

@return string
Generates a random string based on given length .