take the ceiling of a number in php

To take the ceiling of a number in PHP, you can use the built-in ceil() function. This function returns the smallest integer greater than or equal to the input number.

Here's an example:

main.php
$num = 3.14;
$ceiling = ceil($num);
echo $ceiling; // outputs 4
64 chars
4 lines

In this example, the variable $num is assigned the value 3.14. The ceil() function is called on $num, and the result is assigned to the variable $ceiling. Finally, the value of $ceiling is echoed to the screen, which in this case is 4.

related categories

gistlibby LogSnag