Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7920065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:04:41+00:00 2026-06-03T16:04:41+00:00

I want to convert numbers in base 36 using PHP. The function base_convert is

  • 0

I want to convert numbers in base 36 using PHP. The function base_convert is not working because I want to convert large numbers: I don’t get my initial number if I convert it again from base 36 to decimal.

I tried some function given on multiple websites, but I never get the same result. Also, these two websites (in Javascript) give the same result:

  • http://www.unitconversion.org/numbers/base-10-to-base-36-conversion.html
  • http://www.translatorscafe.com/cafe/units-converter/numbers/calculator/decimal-to-base-36/

For example 1010701001118000000000000000 has to be converted to 3IZS0ZE1RQ68W8SSW4.

Here are the functions I tried (and which don’t work):

  • http://www.php.net/manual/fr/function.base-convert.php#34510
  • http://www.php.net/manual/fr/function.base-convert.php#106546
  • http://www.tonymarston.net/php-mysql/showsource.php?file=converter.php
  • http://www.geoffray.be/blog/php/convertir-des-nombres-en-base-62
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:04:42+00:00Added an answer on June 3, 2026 at 4:04 pm

    Here are two simple functions using an algorithm found on Wikipedia, while using bcmath to get the calculations even for very large numbers right:

    function fromDecimalToBase($in, $to) {
        $in = (string) $in;
        $out = '';
    
        for ($i = strlen($in) - 1; $i >= 0; $i--) {
            $out = base_convert(bcmod($in, $to), 10, $to) . $out;
            $in = bcdiv($in, $to);
        }
    
        return preg_replace('/^0+/', '', $out);
    }
    
    function fromBaseToDecimal($in, $from) {
        $in = (string) $in;
        $out = '';
    
        for ($i = 0, $l = strlen($in); $i < $l; $i++) {
            $x = base_convert(substr($in, $i, 1), $from, 10);
            $out = bcadd(bcmul($out, $from), $x);
        }
    
        return preg_replace('/^0+/', '', $out);
    }
    

    However, I get 3izs0ze1rq66tifrpc for the number you’ve provided – maybe your conversion was wrong there?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Python 2.6 I want to be able to convert numbers such as 00000,
I want to convert an array of unsigned short numbers to float using SSE.
I want to convert all numbers with 6 digits to the word million. like
I want to convert a view ID into a URL using EL. The purpose
I want to convert NSString to NSNumber without using numbreFromString: method? The numbreFromString: metgod
Suppose I am working on a card game, and I am using the numbers
I want to convert all numbers to the nearest .25 So... 5 becomes 5.00
I have strings(phone numbers) like this: 1112223333 1234567890 And I want to convert these
I need a base_convert() function that works from base 2 up to base 62
I want just numbers. string str_a = a1bc2d23ghj2; int in_b = convert.toint32(str_a); // doesn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.