Generate the serial number (compress the 12-bit time value into a combination of 7-8 letters and numbers) php code
/*** Generate the serial number ** to compress the 12-digit time value into a combination of 7-8 letters and numbers. The key point is that the user number will never be repeated. * usage: $ serial_no = sofn_generate_serial ('kh '. $ this-> user_login_data ['id']); * Example: QBVF4346 (8-bit, sofn_generate_serial () after 160121054346 (12-bit, date ('ymdhis ') compression ()) * @ param string $ serial_no serial number prefix, for example, 'kh '. $ this-> user_login_data ['id'] * @ return string such as: QBVF295 * @ since VER: 1.0; DATE: 2016-1-21; AUTHOR: SoChishun; EMAIL: 14507247@qq.com; DESC: Added. */function sofn_generate_serial ($ serial_no = '') {$ time = date ('Y-m-d-H-I-s '); $ atime = explode ('-', $ time); foreach ($ atime as $ stime) {$ itime = $ stime * 1; if ($ itime <26) {// 65 (A)-90 (Z) $ serial_no. = chr (65 + $ itime); continue;} // 48 (0)-57 (9) if ($ itime >=48 & $ itime <= 57) {$ serial_no. = chr ($ stime); continue;} $ serial_no. = $ stime;} return $ serial_no ;}