Created
August 1, 2017 07:24
-
-
Save dertajora/2450fbd09bbc9b0ae05e55055eb86cc0 to your computer and use it in GitHub Desktop.
Rounding number to nearest multiple number you want
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function round_up_to_nearest_n($int, $n) { | |
return ceil($int / $n) * $n; | |
} | |
//result will be 10100 | |
round_up_to_nearest(10001,100); | |
//result will be 100000 | |
round_up_to_nearest(85000,50000); | |
//result will be 1000000 | |
round_up_to_nearest(934353,100000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment