73function random_string(
int $iNumOfChars = 8,
string $aType=
"alphanum"): string
75 switch(strtolower($aType))
78 $salt =
'abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
83 $salt =
'abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
87 $salt =
'abcefghijklmnopqrstuvwxyz';
95 $salt =
"abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890?!&_-*%@:.|";
99 $salt = (is_array($aType)) ? implode(
"", $aType) : (string) $aType ;
103 $max = strlen($salt);
104 if ($iNumOfChars > $max) {
107 }
while (strlen($salt) < $iNumOfChars);
110 return substr(str_shuffle($salt), 0, $iNumOfChars);