Say I have the two following numbers:
$a = 77.5;
$b = 74.5;
How would I get the following:
$a = 80;
$b = 70;
I have looked at round, ceil and floor but I can't figure out how to do it.
Thank you.
PHP supports negative precision for its round
function:
$a = round($a, -1);
it's pretty much the same as writing:
$a = round($a/10)*10;
You've got to move your decimals over some, then ceil
-ify.
ceil($a/10)*10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With