5
What is the function of php to round up?
Example:
1.1
move on to 2
5
What is the function of php to round up?
Example:
1.1
move on to 2
9
Use the function ceil()
.
echo ceil(1.1);
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
4
In PHP to top up is used the function ceil
.
Example
echo ceil(4.3); // 5
4
Use the function ceil
.
ceil(1.1); // Imprime 2
This function is usually used to know the number of pages that will be generated in a pagination.
Example:
$total = 100;
$limit = 12;
$pages = ceil($total / $limit); // Imprime 9
It serves to round fractions up.
Just so you have information adds: The function contrary to this is floor
. She rounds it down.
2
<?php
echo ceil(1.1); // 2
echo ceil(4.3); // 5
echo ceil(9.999); // 10
echo ceil(-3.14); // -3
?>
Browser other questions tagged php mathematics
You are not signed in. Login or sign up in order to post.
My vows are over, then I vote for the others.
– Maniero
what we can do when so many equal answers arise?
– Wallace Maxters
I simply accept what is most voted and that’s that
– Amadeu Antunes
@Wallacemaxters don’t have much to do. In this case no one copied from anyone (who would no longer have much to do but comment for the person to avoid this).
– Maniero
@Wallacemaxters do not find it necessary. Yours and even others to a lesser degree have different characteristics that can help in general understanding.
– Maniero
ok. I added more information.
– Wallace Maxters
They are giving +1 sick now. Is the intention to generate "removed serial votes" on purpose? kkkkkk
– Wallace Maxters
@Wallacemaxters this does not reverse.
– Maniero