Split and merge

$ number = some number;

When I divide this number, it does not give a rounded value.

May give something like 3.13.

How to round it to the highest value?

how

if ($number == 3.5) {
    $number = 4;
} elseif ($number = 3.51) {
   $number = 4;
} else if ($number == 3.49) {
   $number = 3;
}
+3
source share
2 answers

Just use the built-in function round(). You can specify the accuracy (how many decimal places you want) using this function round($float,$precision).

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

+5
source

How about round

+1
source

Source: https://habr.com/ru/post/1764568/


All Articles