James
James

Reputation: 43617

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;
} elseif ($number = 3.51) {
   $number = 4;
} else if ($number == 3.49) {
   $number = 3;
}

Upvotes: 3

Views: 3890

Answers (2)

Robert
Robert

Reputation: 21388

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

Upvotes: 5

JonH
JonH

Reputation: 33141

What about round

Upvotes: 1

Related Questions