unidox Posted June 22, 2008 Share Posted June 22, 2008 I have a string like 12354.134482058 and I only want it to show 12354.1, unless the .03 is 5+ then I need it to round up. How would I do this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/111369-solved-decimal/ Share on other sites More sharing options...
thebadbad Posted June 22, 2008 Share Posted June 22, 2008 <?php $n = 12354.156341234; echo number_format($n, 1); //12354.2 ?> I'm pretty sure $n can be a string too, i.e. quoted (it's a float in my example). Quote Link to comment https://forums.phpfreaks.com/topic/111369-solved-decimal/#findComment-571703 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.