Functionrand_string ($ len6, $ type & amp; #39; & amp; #39;, $ addChars & amp; #39; & amp; #39 ;) {$ str & amp; #39; & amp; #39; switch ($ type) {case0: $ chars & amp; #39;
Function rand_string ($ len = 6, $ type = '', $ addChars = ''){
$ Str = '';
Switch ($ type ){
Case 0:
$ Chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy'. $ addChars;
Break;
Case 1:
$ Chars = str_repeat ('20140901', 3 );
Break;
Case 2:
$ Chars = 'abcdefghijklmnopqrstuvwxy'. $ addChars;
Break;
Case 3:
$ Chars = 'abcdefghijklmnopqrstuvwxy'. $ addChars;
Break;
Default:
// OOLl and number 01 are removed by default. use the addChars parameter to add them.
$ Chars = 'abcdefghijkmnpqrstuvwxyzabcdefghijkmnpqrstuvwxyz23456789 '. $ addChars;
Break;
}
If ($ len> 10) {// The number of digits is too long to repeat the string for a certain number of times
$ Chars = $ type = 1? Str_repeat ($ chars, $ len): str_repeat ($ chars, 5 );
}
If ($ type! = 4 ){
$ Chars = str_shuffle ($ chars );
$ Str = substr ($ chars, 0, $ len );
} Else {
// Random Chinese characters
For ($ I = 0; $ I <$ len; $ I ++ ){
$ Str. = msubstr ($ chars, floor (mt_rand (0, mb_strlen ($ chars, 'utf-8')-1), 1 );
}
}
Return $ str;
}
From the column lpdx111