Convert a 10-digit integer to a 62-digit function

Source: Internet
Author: User
* ** Convert 10 to 62 in hexadecimal order ** @ paraminteger $ n10 in hexadecimal order * @ returnstring62 in hexadecimal order * functiondec62 ($ n) {$ base = 62; $ index = & amp; 39; 0123456789
/*** Convert 10 to 62 in hexadecimal format ** @ param integer $ n 10 in hexadecimal value * @ return string 62 in hexadecimal format */function dec62 ($ n) {$ base = 62; $ index = 'hangzhou'; $ ret = ''; for ($ t = floor (log10 ($ n)/log10 ($ base )); $ t> = 0; $ t --) {$ a = floor ($ n/pow ($ base, $ t); $ ret. = substr ($ index, $ a, 1); $ n-= $ a * pow ($ base, $ t);} return $ ret ;}

 

/*** Convert from 62 to 10 ** @ param integer $ n 62 * @ return string 10 */function dec10 ($ s) {$ base = 62; $ index = '0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz '; $ ret = 0; $ len = strlen ($ s)-1; for ($ t = 0; $ t <= $ len; $ t ++) {$ ret + = strpos ($ index, substr ($ s, $ t, 1) * pow ($ base, $ len-$ t);} return $ ret;

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.