Reputation: 4705
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.
Upvotes: 4
Views: 3564
Reputation: 265928
PHP supports negative precision for its round function:
round
$a = round($a, -1);
it's pretty much the same as writing:
$a = round($a/10)*10;
Upvotes: 10
Reputation: 57318
You've got to move your decimals over some, then ceil-ify.
ceil
ceil($a/10)*10
Upvotes: 2