Vivid Lust Posted January 13, 2010 Share Posted January 13, 2010 Does anyone have a function that rounds a number up to the nearest 10? e.g 20 => 20 21 => 30 29 => 30 thanks! Quote Link to comment https://forums.phpfreaks.com/topic/188323-roound-up-to-nearst-10/ Share on other sites More sharing options...
salathe Posted January 13, 2010 Share Posted January 13, 2010 $number = 21; echo round_up_to_ten($number); function round_up_to_ten($i) { return (int) (ceil($i / 10) * 10); } Quote Link to comment https://forums.phpfreaks.com/topic/188323-roound-up-to-nearst-10/#findComment-994175 Share on other sites More sharing options...
JamesThePanda Posted January 13, 2010 Share Posted January 13, 2010 what does ceil do? Quote Link to comment https://forums.phpfreaks.com/topic/188323-roound-up-to-nearst-10/#findComment-994193 Share on other sites More sharing options...
salathe Posted January 13, 2010 Share Posted January 13, 2010 Rounds a number up to an integer; e.g. ceil(2.345) rounds up to 3. Full info on the ceil manual page. Quote Link to comment https://forums.phpfreaks.com/topic/188323-roound-up-to-nearst-10/#findComment-994195 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.