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
精彩评论