RE: Currency and number types...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You might try this:
http://us2.php.net/manual/en/function.money-format.php

Money_format()

In your database query, you can probably format the number how you want
there too... Before you even get to PHP and round()ing it inside PHP.
But do your math and using the money_format() function to display it
should work just fine I think.

-TG

> -----Original Message-----
> From: Mark Benson [mailto:markbenson@xxxxxxx] 
> Sent: Friday, November 19, 2004 12:36 PM
> To: php-db@xxxxxxxxxxxxx
> Subject:  Currency and number types...
> 
> 
> I'm trying to display data calculated by my script as a 
> currency. The problem I have is that PHP is treating the 
> results of the math as a 'float' number (or 'double') so I am 
> getting results like:
> 
> 12.0594393
> 
> in my table. I have tried using:
> 
> print round($foobar,2)
> 
> but that cuts off the trailing zero on numbers that comne out 
> as, for example '12.10' or '12.00'.
> 
> Does anyone know a way to force PHP to print numbers to a set 
> number of significant figures (i.e. 2) and stop the trailing 
> zero suppression?
> 
> -- 
> Mark Benson
> 
http://homepage.mac.com/markbenson

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux