Round up to the nearest integer:
<?phpecho(ceil(0.60) . "<br>");echo(ceil(0.40) . "<br>");echo(ceil(5) . "<br>");echo(ceil(5.1) . "<br>");echo(ceil(-5.1) . "<br>");echo(ceil(-5.9));?>The ceil() function rounds up to the nearest integer.
Tip: To round down to the nearest integer, check out the floor() function.
Tip: To round floating point numbers, check out the round() function.
ceil( number );
parameter | describe |
---|---|
number | Required. Specifies the value to be rounded up. |
Return value: | The nearest integer value rounded up. |
---|---|
Return type: | Float |
PHP version: | 4+ |