Mad*_*iha 12
/**
* Round a number up to the nearest multiple of $n.
*
* @param int $int Number to round.
* @param int $n Round to the nearest $n.
*
* @return int
*/
function round_up_to_nearest_n($int, $n) {
return ceil($int / $n) * $n;
}
echo round_up_to_nearest_n(74268, 50000); //Outputs 100000
Run Code Online (Sandbox Code Playgroud)
除以你要反对的数字,进行舍入,然后再乘以它.
| 归档时间: |
|
| 查看次数: |
2074 次 |
| 最近记录: |