problem with small number format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
123newbiephp
Forum Newbie
Posts: 4
Joined: Mon Nov 07, 2005 8:16 am

problem with small number format

Post by 123newbiephp »

hi,

I'm having trouble outputting a value of lets say 2599 as 25.99. Is there a function that does this for you?

I've looked at number_format(), but this is only useful for dividing a number into thousands, rather than into tens.

Any help is much appreciated.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

well if you divide any number by 100 it moves the decimal places two places to the left... :-D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if the number isn't in the proper format, number_format() isn't at fault.. divide the number by 100..
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

If you're working with integers as your input, run them through intval().
Post Reply