4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Formatting numbers
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Kdawg
Senior WebHelper
Senior WebHelper


Joined: 21 Apr 2003
Posts: 153

PostPosted: Tue May 13, 2003 8:43 pm (14 years, 5 months ago) Reply with QuoteBack to Top

Im doing batting averages on my site and want to format a number like this,
0 = .000 and .11 = .110 etc.
OfflineView User's ProfileFind all posts by KdawgSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Wed May 14, 2003 5:28 am (14 years, 5 months ago) Reply with QuoteBack to Top

http://www.php.net/manual/en/function.number-format.php is your friend Wink

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Kdawg
Senior WebHelper
Senior WebHelper


Joined: 21 Apr 2003
Posts: 153

PostPosted: Wed May 14, 2003 4:33 pm (14 years, 5 months ago) Reply with QuoteBack to Top

That works perfect, but is there a way to take the 0 off the front
0.500 > .500
OfflineView User's ProfileFind all posts by KdawgSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Wed May 14, 2003 4:40 pm (14 years, 5 months ago) Reply with QuoteBack to Top

Not sure, but I can provide a dirty way of doing it Razz

Code:
$variable = str_replace('0.', '.', $variable);

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Wed May 14, 2003 4:55 pm (14 years, 5 months ago) Reply with QuoteBack to Top

explode() would have been my suggestion, but I guess str_replace is just as good.

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.051999 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme