ankur0101 Posted April 22, 2009 Share Posted April 22, 2009 Hi, $percentage = '72.76986325' How can make it 73 ? after 72., its 7 which is greater than 5 If number is greater than or equal to 5, then add 1 to previous number Like this 72.86669856, then it should be 73 72.23669994, then it should be 72 How to do that in PHP ? Quote Link to comment https://forums.phpfreaks.com/topic/155205-solved-what-to-do-this-such-cases-i-am-confused/ Share on other sites More sharing options...
premiso Posted April 22, 2009 Share Posted April 22, 2009 round should do it. Parameters val The value to round precision The optional number of decimal digits to round to, defaults to 0 mode One of PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EV Set the mode to PHP_ROUND_HALF_UP and it should work like you want, but that is the default I believe so it is not necessary to specify it. Quote Link to comment https://forums.phpfreaks.com/topic/155205-solved-what-to-do-this-such-cases-i-am-confused/#findComment-816469 Share on other sites More sharing options...
ILMV Posted April 22, 2009 Share Posted April 22, 2009 You should probably start checking http://php.net, just search for the keywork your looking for. In this instance, this is what you want http://uk.php.net/round Quote Link to comment https://forums.phpfreaks.com/topic/155205-solved-what-to-do-this-such-cases-i-am-confused/#findComment-816470 Share on other sites More sharing options...
ankur0101 Posted April 22, 2009 Author Share Posted April 22, 2009 Hey ILMV ad premiso, thanks for that Its working ... Quote Link to comment https://forums.phpfreaks.com/topic/155205-solved-what-to-do-this-such-cases-i-am-confused/#findComment-816489 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.