[英]PHP round up value
I have value like this我有这样的价值
13/12 = 1.083333333
what i want is我想要的是
13/12 = 2
I already tried round,it not what I expected.我已经试过了,这不是我所期望的。
Please anyone help.请任何人帮助。
you can use the ceil
function.您可以使用
ceil
function。
What you're looking for is the ceil()
function.您正在寻找的是
ceil()
function。 It automatically rounds any partial values up to the next whole integer.它会自动将任何部分值四舍五入到下一个整数 integer。
$value = 13/12;
$rounded = ceil($value);
echo "Value: " . $rounded;
PHP also has a corresponding floor()
function, which rounds down to the nearest whole integer. PHP 也有一个对应的
floor()
function,它向下舍入到最接近的整数 integer。
like this?像这样? (round(13/12,0,PHP_ROUND_HALF_UP)
(回合(13/12,0,PHP_ROUND_HALF_UP)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.