nzol Posted January 7, 2011 Share Posted January 7, 2011 Hi all, Can anyone please help me with my problem. I want to know how to round a decimal - eg. 12.34 to the nearest .10 so it would be 12.30 or if 12.35 go to 12.30 or 12.40. // my example: round(12.34, 2); // I want to to go to: 12.30 Any help is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
sooner Posted January 7, 2011 Share Posted January 7, 2011 since this the result you need...you have to write some functions to make that number..because in normal if you round that number it won't go to 12.30 or 12.40 as you are expecting.....see php website for the round function..under that many people have some sample codes for different kind of output...see whether you get one from there or you get an idea from there.. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 7, 2011 Share Posted January 7, 2011 money_format may be of some help to you. Quote Link to comment Share on other sites More sharing options...
DavidAM Posted January 7, 2011 Share Posted January 7, 2011 Are you trying to round to one decimal place, and then display it to two decimal places? number_format(round(12.34, 1), 2); Quote Link to comment Share on other sites More sharing options...
nzol Posted January 7, 2011 Author Share Posted January 7, 2011 @DavidAM >> THANK YOU SOOOOO MUCH! I SOLVED IT. 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.