开发者

Divide and round

开发者 https://www.devze.com 2023-01-16 12:50 出处:网络
$number = some number; When I divide this number, it gives not a round value. Can give something like 3.13.

$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

精彩评论

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