Skip to content

Instantly share code, notes, and snippets.

@dertajora
Created August 1, 2017 07:24
Show Gist options
  • Save dertajora/2450fbd09bbc9b0ae05e55055eb86cc0 to your computer and use it in GitHub Desktop.
Save dertajora/2450fbd09bbc9b0ae05e55055eb86cc0 to your computer and use it in GitHub Desktop.
Rounding number to nearest multiple number you want
<?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