php取整怎么以5为界
/**
+-------------------------------------------------
* @param int $amount 目标数字
+-------------------------------------------------
* @param int $num 向上取整的位数
+-------------------------------------------------
* @param int $scope 界数,1-10的数字
+-------------------------------------------------
* @return int
+-------------------------------------------------
*/
function rounding($amount,$num,$scope)
{
$change = 1;
for($i = 1;$i < $num;$i++){
$change = $change * 10;
}
$temp = floor($amount/$change);
if($temp%10 < $scope){
$return = floor($temp/10)*10 + $scope;
}else{
$return = (floor($temp/10)+1)*10;
}
return $return * $change;
}
echo rounding(221529,5,5);
大神,不知您是否有空回复一下,以5为界向上取整怎么解决,谢谢大神