开发者

Divide and round

$number = some number;

When I divide this number, it gives not a round value.

Can give something like 3.13.

How to round it to the biggest value?

Like:

if ($number == 3.5) {
    $number = 4;
} e开发者_StackOverflowlseif ($number = 3.51) {
   $number = 4;
} else if ($number == 3.49) {
   $number = 3;
}


Just use the built in function round(). You can specify precision(how many decimal points you want) by using the function like so round($float,$precision).

http://php.net/manual/en/function.round.php


What about round

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜