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
123newbiephp
Forum Newbie
Posts: 4 Joined: Mon Nov 07, 2005 8:16 am
Post
by 123newbiephp » Mon Nov 07, 2005 8:36 am
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 » Mon Nov 07, 2005 8:38 am
well if you divide any number by 100 it moves the decimal places two places to the left...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Nov 07, 2005 8:39 am
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 » Mon Nov 07, 2005 10:34 am
If you're working with integers as your input, run them through
intval() .