src/Data/String.php
public static function getRandomString($pLength = 6, $pStrength = 1)
    {
    	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    	if ($pStrength >= 1) {
            $chars .= '0123456789';
    	}

    	if ($pStrength >= 2) {
            $strengthChars = '@#$%';
            $chars        .= $strengthChars;
    	}

    	$str = '';
    	for ($i = 0; $i < $pLength; $i++) {
            $str .= $chars[(rand() % strlen($chars))];
    	}

        if ($pStrength >= 2 and ! preg_match('/@|#|\$|%/', $str)) {
            $str = substr($str, 0, -1);
            $str = preg_replace("/^(.{" . (rand() % $pLength) ."})/", "$1" . $strengthChars[rand() % strlen($strengthChars)], $str);
        }

    	return $str;
    }
public static function getRandomString($pLength = 6, $pStrength = 1)
    {
    	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    	if ($pStrength >= 1) {
            $chars .= '0123456789';
    	}

    	if ($pStrength >= 2) {
            $strengthChars = '@#$%';
            $chars        .= $strengthChars;
    	}

    	$str = '';
    	for ($i = 0; $i < $pLength; $i++) {
            $str .= $chars[(rand() % strlen($chars))];
    	}

        if ($pStrength >= 2 and ! preg_match('/@|#|\$|%/', $str)) {
            $str = substr($str, 0, -1);
            $str = preg_replace("/^(.{" . (rand() % $pLength) ."})/", "$1" . $strengthChars[rand() % strlen($strengthChars)], $str);
        }

    	return $str;
    }
public static function getRandomString ( $ pLength = 6 , $ pStrength = 1 ) { $ chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; if ( $ pStrength >= 1 ) { $ chars .= '0123456789' ; } if ( $ pStrength >= 2 ) { $ strengthChars = '@#$%' ; $ chars .= $ strengthChars ; } $ str = '' ; for ( $ i = 0 ; $ i < $ pLength ; $ i ++ ) { $ str .= $ chars [ ( rand ( ) % strlen ( $ chars ) ) ] ; } if ( $ pStrength >= 2 and ! preg_match ( '/@|#|\$|%/' , $ str ) ) { $ str = substr ( $ str , 0 , - 1 ) ; $ str = preg_replace ( "/^(.{" . ( rand ( ) % $ pLength ) . "})/" , "$1" . $ strengthChars [ rand ( ) % strlen ( $ strengthChars ) ] , $ str ) ; } return $ str ; }
Return a random string with a variable length and strength.

@param int $pLength Length of the string to generate
@param int $pStrength Strength of the string to generate
@return string Random string
Return a random string with a variable length and strength .