Newscoop\NewscoopBundle\Controller\PasswordRecoveryController::generateRandomString PHP Method

generateRandomString() public method

Get random string
public generateRandomString ( integer $length = 12, string $allowedChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ) : string
$length integer String length
$allowedChars string Chars allowed
return string
    public function generateRandomString($length = 12, $allowedChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
    {
        $return = '';
        for ($i = 0; $i < $length; $i++) {
            $return .= $allowedChars[mt_rand(0, strlen($allowedChars) - 1)];
        }
        return $return;
    }