DaveLinger Posted July 22, 2007 Share Posted July 22, 2007 So I have an assortment of numbers coming in, they're all zero point something. I want them to round to zero point number number - like currency... $0.XX. Problem I'm running into is that when I do round($var, 2), it cuts off trailing zeros, so some numbers end up as $0.X, because the next number would have been a zero. How do I keep that on there? Quote Link to comment Share on other sites More sharing options...
dbo Posted July 22, 2007 Share Posted July 22, 2007 Look into sprintf... I don't remember the exact syntax. Quote Link to comment Share on other sites More sharing options...
DaveLinger Posted July 22, 2007 Author Share Posted July 22, 2007 got it: sprintf("%01.2f", $var) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.