逢4进5,逢5进10。0,5值不变

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
//逢4进5,逢5进10。0,5值不变
function ceiling($number = 0){

if($number == 0){
return 0;
}

//这里取出整数
$number = explode('.',$number);
$number = $number[0];

$cc = $number%10;
$price = $number;
if($cc > 5){
$price = $number+(10-$cc);
}elseif ($cc > 0) {
$price = $number+(5-$cc);
}
return $price;
}