其他分享
首页 > 其他分享> > 缩短

缩短

作者:互联网

function shorturl($url)
{
    $url = crc32($url);
    $result = sprintf("%u", $url);
    return code62($result);
}
function code62($x)
{
    $show = '';
    while ($x > 0) {
        $s = $x % 62;
        if ($s > 35) {
            $s = chr($s + 61);
        } elseif ($s > 9 && $s <= 35) {
            $s = chr($s + 55);
        }
        $show .= $s;
        $x = floor($x / 62);
    }
    return $show;
}

 

标签:function,return,show,url,缩短,result,code62
来源: https://www.cnblogs.com/chengfengchi/p/15076469.html