webdancer Posted December 19, 2010 Share Posted December 19, 2010 I am trying to take a number (three for example) and want to round it to five, or sixty-seven up to seventy. I looked at round and ceil, but those don't seem like they are the right things. Thanks, Joseph Quote Link to comment Share on other sites More sharing options...
johnny86 Posted December 19, 2010 Share Posted December 19, 2010 function ceilTo($num, $to) { return ceil($num / $to) * $to; } echo ceilTo(12, 5); // Prints: 15 echo ceilTo(121, 5); // Prints 125 echo ceilTo(120, 5); // Prints 120 Quote Link to comment Share on other sites More sharing options...
webdancer Posted December 19, 2010 Author Share Posted December 19, 2010 Awesome, that works great. Thanks a lot, Joseph 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.