PHP ceil() function
The ceil() function is used to round a float value to the nearest integer value. This is basically used in mathematical problems to round up the decimal value to the next highest integer value.
Syntax
float ceil(value);
It takes single integer or float value in parameter and returns round up value to the nearest higher integer.
Example of ceil()
<?php
// Positive decimal number
echo ceil(0.21).'<br/>';
// Negative decimal number
echo ceil(- 0.21).'<br/>';
// Positive decimal number
echo ceil(0.27).'<br/>';
// Positive number
echo ceil(6).'<br/>';
// Negative number
echo ceil(-6).'<br/>';
// Negative decimal number
echo ceil(-6.9).'<br/>';
?>
Output :
1
-0
1
6
-6
-6
Related PHP Functions
PHP array_reverse() functionPHP array_diff() function
PHP array_key_exists() function
PHP array_push() function
PHP array_search() function
PHP class_exists() function
PHP curl_setopt() function
PHP die() function
PHP dirname() function
PHP each() function
PHP explode() function
PHP file_exists() function
PHP function_exists() function
PHP getenv() function
PHP is_readable() function
PHP ksort() function
PHP mkdir() function
PHP ob_start() function
PHP parse_url() function
PHP str_repeat() function
PHP substr() function