Reputation: 167
Can You help me to figure this out. I need to round number to cents if there is atleast one 0.001. So it has to be 0.01 or if 1.133 it has to be 1.14. I tried many ways like
number_format(round($number, 1, PHP_ROUND_HALF_UP), 2);
and etc... Still nothing helps.
Upvotes: 0
Views: 386
Reputation: 11328
You can use ceil()
to round up. Unfortunately, you can't specify to how many decimals, so you'll have to multiply and divide:
$number = ceil($number * 100) / 100;
Upvotes: 4