note 89888 added to function.number-format
| From: | jamesatbanditdotco dot nz at osu1 dot php dot net | Date: | Fri, 27 Mar 2009 05:03:53 +0000 |
| Subject: | note 89888 added to function.number-format | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152511@lists.php.net to get a copy of this message | ||
Outputs a human readable number.
<?php
# Output easy-to-read numbers
# by james at bandit.co.nz
function bd_nice_number($n) {
// first strip any formatting;
$n = (0+str_replace(",","",$n));
// is this a number?
if(!is_numeric($n)) return false;
// now filter it;
if($n>1000000000000) return round(($n/1000000000000),1).' trillion';
else if($n>1000000000) return round(($n/1000000000),1).' billion';
else if($n>1000000) return round(($n/1000000),1).' million';
else if($n>1000) return round(($n/1000),1).' thousand';
return number_format($n);
}
?>
Outputs:
247,704,360 -> 247.7 million
866,965,260,000 -> 867 billion
----
Server IP: 203.89.181.186
Probable Submitter: 121.73.158.245
----
Manual Page -- http://www.php.net/manual/en/function.number-format.php
Edit -- https://master.php.net/note/edit/89888
Del: integrated -- https://master.php.net/note/delete/89888/integrated
Del: useless -- https://master.php.net/note/delete/89888/useless
Del: bad code -- https://master.php.net/note/delete/89888/bad+code
Del: spam -- https://master.php.net/note/delete/89888/spam
Del: non-english -- https://master.php.net/note/delete/89888/non-english
Del: in docs -- https://master.php.net/note/delete/89888/in+docs
Del: other reasons-- https://master.php.net/note/delete/89888
Reject -- https://master.php.net/note/reject/89888
Search -- https://master.php.net/manage/user-notes.php