RE: [PHP-DB] Currency and number types...

2004-11-19 Thread Bastien Koert
number_format() is what you need
look it up
bastien
From: Mark Benson <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Currency and number types...
Date: Fri, 19 Nov 2004 17:35:53 +
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


RE: [PHP-DB] Currency and number types...

2004-11-19 Thread Gryffyn, Trevor
Either way. :)

> -Original Message-
> From: Joseph Crawford [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 19, 2004 12:48 PM
> To: Gryffyn, Trevor; [PHP-DB] Mailing List
> Subject: Re: [PHP-DB] Currency and number types...
> 
> 
> how about good old number_format()
> 
> -- 
> Joseph Crawford Jr.
> Codebowl Solutions
> [EMAIL PROTECTED]
> 
> For a GMail account
> contact me OFF-LIST
> 

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



Re: [PHP-DB] Currency and number types...

2004-11-19 Thread Joseph Crawford
how about good old number_format()

-- 
Joseph Crawford Jr.
Codebowl Solutions
[EMAIL PROTECTED]

For a GMail account
contact me OFF-LIST

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



RE: [PHP-DB] Currency and number types...

2004-11-19 Thread Gryffyn, Trevor
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:[EMAIL PROTECTED] 
> Sent: Friday, November 19, 2004 12:36 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] 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