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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:00:54+00:00 2026-06-05T02:00:54+00:00

Something like this: echo somefn(2800000000); // outputs ‘2,8B’ for 2,8 billion echo somefn(2000000); //

  • 0

Something like this:

echo somefn(2800000000); // outputs '2,8B' for 2,8 billion
echo somefn(2000000); // outputs '2M' for 2 million
echo somefn(5400); // outputs '5,4K' for 5,400
echo somefn('blabla') // outputs 'blabla' as it is because it isn't a number
echo somefn(5) // outputs 5, nothing to simplify

I know it must be really easy code but I wonder if anyone else has something that accounts for maybe other cases that don’t pop in my head right now.

/Edit I’m looking for something more in the lines of a generalized, built-in PHP function (or something close to that). Pretty much the same way strtotime() can handle things like “weeks” or “months”.

  • 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-05T02:00:57+00:00Added an answer on June 5, 2026 at 2:00 am

    I don’t know of any off the shelf function you can call. Here’s one possible solution:

    function number_abbr($number) {
      if (!is_numeric($number) || $number < 1000)
        return $number;
    
      $postfix = array("K", "M", "B", "T");
      while ($number >= 1000 && count($postfix) > 0) {
        $number /= 1000;
        $append = array_shift($postfix);
      }
    
      // if the number is still greater than 1000...
      if ($number > 1000)
        return "a lot";
    
      // return the output
      return sprintf("%1.1f" . $append, $number);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have something like this: if ($command === 'txt') { header('Content-type: text/plain;charset=utf-8'); echo
I have a script that looks like this #!/bin/bash function something() { echo hello
I've seen something like this: echo ($hello->somethingA->somethingB); What does this mean? I will try
Maybe the code looks like something like this: foreach(...$POST){ echo $key.<br/>; }
I've tried something like this: VAR := $(echo \`find . -name .txt`) but when
So something like this <h2 style='margin-top: 10px;'> <?php echo $title; ?> </h2> should become
Is threre a way to encode something like this : eval(echo 'String';); with base64_encode
date('H-m-s') gives something like this when I echo variable > 08-07-16 I have table
I would like to do something like this: echo $myObject->value_$id but I don't know
I know in php I can do something like this echo {$this->method}; and I

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.