php 这个码怎么逆算
function x10to62($dec) {$dict = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$result = '';
do {
$result = $dict[$dec % 56] . $result;
$dec = intval($dec / 56);
} while ($dec != 0);
return $result;
}
比如100算法得到 Xc
那怎么逆向算呢 :ohh::mad::mad: 好久没玩PHP,这个费脑:ohh: function from62_to10($num) {
$from = 62;
$num = strval($num);
$dict = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$len = strlen($num);
$dec = 0;
for($i = 0; $i < $len; $i++) {
$pos = strpos($dict, $num[$i]);
$dec = bcadd(bcmul(bcpow($from, $len - $i - 1), $pos), $dec);
}
return $dec;
} 娃哈哈 发表于 2021-5-31 17:35
Call to undefined function bcadd()
试了下跑不通呢
echo from62_to10('Av');
function from62_to10($num) {
$from = 62;
$num = strval($num);
$dict = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$len = strlen($num);
$dec = 0;
for($i = 0; $i < $len; $i++) {
$pos = strpos($dict, $num[$i]);
$dec = bcadd(bcmul(bcpow($from, $len - $i - 1), $pos), $dec);
}
return $dec;
} 厉害了,高手如云
页:
[1]