xwishmasterx Posted April 8, 2011 Share Posted April 8, 2011 How can I round this with 2 decimals: echo " $row[team_treasure] "; I've tried round($row[team_treasure],2) but doesn't seem to work inside my echo tags :/ Quote Link to comment https://forums.phpfreaks.com/topic/233154-rounding-values/ Share on other sites More sharing options...
spiderwell Posted April 9, 2011 Share Posted April 9, 2011 then do it outside of them this should work, he says without checking it echo round($row[team_treasure],2); Quote Link to comment https://forums.phpfreaks.com/topic/233154-rounding-values/#findComment-1199047 Share on other sites More sharing options...
xwishmasterx Posted April 9, 2011 Author Share Posted April 9, 2011 what do you mean "outside of them"? My code is: echo " alot of text here and then treasure holdings: ".$row[team_treasure]." and some more text here"; using your (and my) way just returns this: round(845.56999999999999,2) Quote Link to comment https://forums.phpfreaks.com/topic/233154-rounding-values/#findComment-1199052 Share on other sites More sharing options...
spiderwell Posted April 9, 2011 Share Posted April 9, 2011 the first line is what i mean by outside i.e. its not inside quotes, as you can out put variables inline "something $variable ". echo " alot of text here and then treasure holdings: ".round($row['team_treasure'],2)." and some more text here"; //works echo " alot of text here and then treasure holdings:round($row['team_treasure'],2) and some more text here"; //wont work Quote Link to comment https://forums.phpfreaks.com/topic/233154-rounding-values/#findComment-1199053 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.