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 7924131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:34:44+00:00 2026-06-03T17:34:44+00:00

I am playing with Twitter API. Some numbers (like Twitter ID) is really large

  • 0

I am playing with Twitter API. Some numbers (like Twitter ID) is really large such as 199693823725682700.

I’ve got this number as string format, and now I need to change it to just normal readable number, not like 1000xE09, because I need to substract -1 from that string-casted number. Then, I also need to send the number as string.

In sum, in PHP, how can I change the string a number, e.g., “199693823725682700” to another string “199693823725682699” (original number -1)?

Thanks a lot!

  • 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-03T17:34:46+00:00Added an answer on June 3, 2026 at 5:34 pm

    If BCMath is not available (it would be the preferable option if it is available) this function will decrement an arbitrarily sized integer stored as a string. There is no handling for floats or interpolation of scientific notation, it will only work with a string of decimal digits with an optional sign.

    function decrement_string ($str) {
    
      // 1 and 0 are special cases with this method
      if ($str == 1 || $str == 0) return (string) ($str - 1);
    
      // Determine if number is negative
      $negative = $str[0] == '-';
    
      // Strip sign and leading zeros
      $str = ltrim($str, '0-+');
    
      // Loop characters backwards
      for ($i = strlen($str) - 1; $i >= 0; $i--) {
    
        if ($negative) { // Handle negative numbers
    
          if ($str[$i] < 9) {
            $str[$i] = $str[$i] + 1;
            break;
          } else {
            $str[$i] = 0;
          }
    
        } else { // Handle positive numbers
    
          if ($str[$i]) {
            $str[$i] = $str[$i] - 1;
            break;
          } else {
            $str[$i] = 9;
          }
    
        }
    
      }
    
      return ($negative ? '-' : '').ltrim($str, '0');
    
    }
    

    See it working

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

Sidebar

Related Questions

I playing around with the Twitter API for my BlackBerry application. Is there any
I'm playing around with the twitter API and it's returning the following: [ 12345,
Playing with Erlang, I've got a process-looping function like: process_loop(...A long list of parameters
How do stop a multiple Youtube Video's Playing on Twitter Bootstrap Model Close? This
I just started playing around with the Twitter Streaming API and using the command
I'm playing with the Twitter API and noticed something funny- For updates, they require
I am new to OAuth and have been playing around with the Twitter API.
I'm playing with the Twitter API to brush up on my basic python. I'm
After playing around with haskell a bit I stumbled over this function: Prelude Data.Maclaurin>
Im playing a little bit with heavy-client app. Imagine I have this model: class

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.