💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
``` /** * @description: 10进制转36进制 * @param {type} * @return: */ protected function createCode($userId) { static $sourceString = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ]; $num = $userId; $code = ''; while ($num) { $mod = bcmod($num, 36); $num = bcdiv($num, 36); $code = "{$sourceString[$mod]}{$code}"; //邀请码拼接 } //判断code的长度 if (empty($code[4])) $code=str_pad($code, 5, '0', STR_PAD_LEFT); //长度不够拼接'0' return $code; } ```