I know about php's built in round()
function, which return 2
for 1.6
. But it return 1
for 1.1
. I want to return the next number if the given number has a fractional part. For example, I want to return 2
for 1.1
, or 1.01
, or even 1.0001
. But I don't want to return the same for 1.0
, which may return 1
itself. How can I achieve this in PHP?
Take a look at php's ceil()
.
echo ceil(4.3); // 5
echo ceil(9.999); // 10
echo ceil(-3.14); // -3
Use ceil()
to round up to the next number
echo ceil(1.0); // will echo 1
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.