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 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). Link to comment https://forums.phpfreaks.com/topic/111369-solved-decimal/#findComment-571703 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.