theITvideos Posted October 27, 2010 Share Posted October 27, 2010 Hi there. I am trying to display numbers if they have the numbers like: number_format($price,2) This gives us two decimal places i.e 7.23 Now thats fine, I would like to round the last two decimal places. I would like to make it 7.25, (rounding it from 7.23 to 7.25) Similarly making: 12.44 to 12.45 33.18 to 33.20 52.13 to 52.15 So actually rounding the last two places. Coz obviously customers won't be able to pay 52 dollars 13 cents. So therefore rounding the last cent's (decimal part) making it to 52.15 Thank you. All comments and feedback are welcomed. (d Quote Link to comment Share on other sites More sharing options...
abdfahim Posted October 27, 2010 Share Posted October 27, 2010 If I got you correctly .... $str = 52.56123; // Your number $str = ceil($str*100); $str = (($str+5-($str%5))/100); echo $str; 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.