76function random_string(
int $iNumOfChars = 8,
string $aType=
"alphanum"): string
78 switch(strtolower($aType))
81 $salt =
'abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
86 $salt =
'abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
90 $salt =
'ABCDEF0123456789';
94 $salt =
'abcdef0123456789';
98 $salt =
'abcefghijklmnopqrstuvwxyz';
102 $salt =
'1234567890';
106 $salt =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.";
110 $salt = (is_array($aType)) ? implode(
"", $aType) : (string) $aType ;
114 $max = strlen($salt);
115 if ($iNumOfChars > $max)
120 }
while (strlen($salt) < $iNumOfChars);
123 return substr(str_shuffle($salt), 0, $iNumOfChars);