Reputation: 1605
I have read the documentation and have clear idea of round but i didn't find useful information to solve the problem.
The problem is i have float number which is let say 1.09 and i want to display it 2 instead of 1. if we use round function it display 1. Help me solve this problem.
MORE DETAILS...
$TotalPaidRemaining=1090;
$monthly_installments=1000;
$MakingNumberOfMonths=$TotalPaidRemaining/$monthly_installments;
echo round($MakingNumberOfMonths, 0, PHP_ROUND_HALF_UP);// it display 1. i want it display 2..
What i want is if the value after decimal point is greater than 0. For example 0.01. I want to consider it as 1.
Hope i am clear at my question.
Upvotes: 2
Views: 866
Reputation: 57
You could use ceil($yourNumber)
, which will round the number to its next higher integer.
Or you could use round($yourNumber + 0.499999999999999)
.
Or you could use floor($yourNumber + 1)
, which rounds the number to its previous highest integer.
Upvotes: 0
Reputation: 795
You can use the ceil() php function instead of round(). It will round up your values. Docs: http://php.net/manual/en/function.ceil.php
Example:
ceil(1.09); // return 2
Upvotes: 2