php nearest ten-th value
I am getting a max value through value. It开发者_Python百科 can be any digit (whole number). I want it to take to next tenth-value, using PHP
Example:
If value is 66, then I need value 70
If value is 6, then I need value 10 If value is 98, then I need value 100This is an arithmetic problem:
y = ceil(x / 10) * 10
If you’re looking just for the nearest decade, use round
instead.
$num = 66;
$val = ceil($num / 10) * 10;
echo $val;
Thanks.
or
echo round(66,-1);
up to 30 characters
精彩评论