Generate random number (based on conditions and quantity)
Function rand ($ length, $ num ){
$ Result = '';
$ Chars = 'abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxy ';
$ Maxlength = strlen ($ chars)-1;
For ($ I = 1; $ I <= $ num; $ I ++ ){
$ Result = ""; // write to memory first
For ($ j = 1; $ j <= $ length; $ J ++ ){
$ Result. = $ chars [mt_rand (0, $ maxlength)];
}
$ Res [$ I] = $ result;
}
Return $ res;
}
Application: activation code, verification code, 9-9 multiplication form
1 × 1 = 1
1 × 2 = 22 × 2 = 4
1 × 3 = 32 × 3 = 63 × 3 = 9
1 × 4 = 42 × 4 = 83 × 4 = 124 × 4 = 16
1 × 5 = 52 × 5 = 103 × 5 = 154 × 5 = 205 × 5 = 25
1 × 6 = 62 × 6 = 123 × 6 = 184 × 6 = 245 × 6 = 306 × 6 = 36
1 × 7 = 72 × 7 = 143 × 7 = 214 × 7 = 285 × 7 = 356 × 7 = 427 × 7 = × 7 = 49
1x8 = 82x8 = 163x8 = 244x8 = 325x8 = 406x8 = 487x8 = 568x8 = 64
1 × 9 = 92 × 9 = 183 × 9 = 274 × 9 = 365 × 9 = 456 × 9 = 547 × 9 = 638 × 9 = 729 × 9 = 81