[PHP] Formating a Double

2006-09-06 Thread Phillip Baker

Greetings All,

I am trying to format a double to use thousands seperators and such.
number_format does not appear to be working properly for this.
My guess is cause I am trying to format a double rather than a string.
Is there anything out there that will allow me to format a double to include
a comma as a thousands seperator.
Thanks.

--
Blessed Be

Phillip

The House has passed a law that would abandon the Internet's First Amendment
-- a principle called Network Neutrality that prevents companies like ATT,
Verizon and Comcast from deciding which Web sites work best for you -- based
on what site pays them the most. If the public doesn't speak up now, our
elected officials will cave to a multi-million dollar lobbying campaign.
Please contaxct your Senators to defeat this bill in the Senate.
http://www.savetheinternet.com
http://www.coanews.org/tiki-read_article.php?articleId=995
http://www.coanews.org/internetfreedom.html?page=netfreedom
http://www.gnn.tv/headlines/9484/
http://www.dearaol.com/


RE: [PHP] Formating a Double

2006-09-06 Thread Jay Blanchard
[snip]
I am trying to format a double to use thousands seperators and such.
number_format does not appear to be working properly for this.
My guess is cause I am trying to format a double rather than a string.
Is there anything out there that will allow me to format a double to
include
a comma as a thousands seperator.
Thanks.
[/snip]

http://www.php.net/printf

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



RE: [PHP] Formating a Double

2006-09-06 Thread Robert Cummings
On Wed, 2006-09-06 at 11:21 -0500, Jay Blanchard wrote:
 [snip]
 I am trying to format a double to use thousands seperators and such.
 number_format does not appear to be working properly for this.
 My guess is cause I am trying to format a double rather than a string.
 Is there anything out there that will allow me to format a double to
 include
 a comma as a thousands seperator.
 Thanks.
 [/snip]
 
 http://www.php.net/printf

Printf() doesn't do thousands separation as the OP is requiring (unless
they've added that feature since I last read the manual -- and yes I'm
too lazy to go look right now ;)

From the number_format doc though...

string number_format ( float number [, int decimals [, string
dec_point, string thousands_sep]] )

And if I'm not mistaken, PHP doesn't distinguish between floats and
doubles and treats them all as doubles. Number_format() should work fine
as follows:

?php

$foo = 101.2342

echo number_format( $foo );

?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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