customformatters.com icon indicating copy to clipboard operation
customformatters.com copied to clipboard

decimal converter

Open joaoherberto opened this issue 12 years ago • 0 comments

OK, I have spent countless hours trying to get a custom formatter working... but I just don't have the knowledge to code this. I found a PHP snippet that does what I need it to do, but how do I use the code with CustomFormatter?

Basically I want the user to input the actual number that will be in millions, ie: 2,300,587.00 but I want it formated in certain instances as only 2.3 Million etc.

Here is the code:


1000000000000) return round(($n/1000000000000),2).' trillion'; else if($n>1000000000) return round(($n/1000000000),2).' billion'; else if($n>1000000) return round(($n/1000000),2).' million'; else if($n>1000) return round(($n/1000),2).' thousand'; return number_format($n); } ``` echo nice_number('14120000'); //14.12 million ?>

joaoherberto avatar Feb 16 '13 04:02 joaoherberto