Convert long numbers to short characters
/** * 将数字转为短网址代码 * * @param int $number 数字 * @return string 短网址代码 */ function generate_code($number) { $out = ""; $codes = "abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; while ($number > 60) { $key = bcmod($number,'61'); $number = bcsub(bcp($number,'61'),'1'); $out = $codes{$key}.$out; } return $codes{$number}.$out; } /** * 将短网址代码转为数字 * * @param string $code 短网址代码 * @return int 数字 */ function get_num($code){ $codes = "abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $num = 0; $i = strlen($code); for($j=0;$j<strlen($code);$j++){ $i--; $char = $code{$j}; $pos = strpos($codes,$char); $num = bcadd(bcmul(bcpow("61", $i),($pos + 1)),$num); } $num=bcsub($num,"1"); return $num; } /*****函数结束****/ $id="1973337397412392446"; echo $id." "; $did=generate_code($id); echo generate_code($id)." "; echo get_num($did);
The above is the content of converting long numbers to short characters. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools
