Page 1 of 1

Formatting Numbers

Posted: Tue Jun 15, 2004 12:43 pm
by stantheman
I want to be able to fomrat my numbers to something like this
100,000.00

How would i go about this with this function or do i have the wrong function

sprintf("%01.2f", $money);

Posted: Tue Jun 15, 2004 1:19 pm
by dull1554
give it a try, think about how much time you could have saved instead of posting if you just droped it into a php file and gave it a go

Posted: Tue Jun 15, 2004 1:24 pm
by stantheman
i put it into the code but the format i get it 100000.00 but i want 100,000.00

Posted: Tue Jun 15, 2004 2:43 pm
by dull1554
oh ok, well you could make a simple function to count every 3 numbers and insert a ","

but i think to do this you will have to treat the float as a string

Posted: Tue Jun 15, 2004 2:46 pm
by qads
dull1554 wrote:oh ok, well you could make a simple function to count every 3 numbers and insert a ","
really? :P

[php_man]number_format[/php_man]

Posted: Tue Jun 15, 2004 2:50 pm
by dull1554
*opens mouth and inserts foot*
after posting i dusted off the old php manual and found it, i just thought to hit f5 before i made an even bigger fool of myself

sorry for the slight oversight......

Posted: Tue Jun 15, 2004 5:24 pm
by tim
dull1554 wrote:*opens mouth and inserts foot*
after posting i dusted off the old php manual and found it, i just thought to hit f5 before i made an even bigger fool of myself

sorry for the slight oversight......
lol dont worry, i never knew about that function either. My memory was refreshed when I seen it

:wink: