Jyxo\StringUtil::random PHP Method

random() public static method

Generates a random string of given length.
public static random ( integer $length ) : string
$length integer String length
return string
    public static function random(int $length) : string
    {
        static $chars = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $random = '';
        for ($i = 1; $i <= $length; $i++) {
            $random .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
        }
        return $random;
    }