Back to PhocacartUtils class

Method getRandomString

public static
getRandomString
(mixed $length = '')

Method getRandomString - Source code

public static function getRandomString($length = '')
{
    $code = md5(uniqid(rand(), true));
    if ($length != '' && (int) $length > 0) {
        $length = $length - 1;
        return chr(rand(97, 122)) . substr($code, 0, $length);
    } else {
        return chr(rand(97, 122)) . $code;
    }
}