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! 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); } 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? 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. 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
Archived
This topic is now archived and is closed to further replies.