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.
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.