9月72021
10进制转62进制 php函数
//10进制转为62进制 function dec62($val) { $str = ''; $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; do { $i = $val % 62; $str = $chars[$i] . $str; $val = ($val - $i) / 62; } while ($val > 0); return $str; } //62进制转为10进制 function dec10($s) { $index = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $ret = 0; $len = strlen($s) - 1; for($t = 0; $t <= $len; $t ++) { $ret += strpos($index, substr($s, $t, 1)) * pow(62, $len - $t); } return $ret; }
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!