How to round one up numbers in php?
In this post, this function will round the number to one a unit in php.
1. Code:
<?php
function roundOneUp($number){
$n = (int)$number;
$frac = $number - $n;
if ($frac > 0) {
$number = $n + 1;
}
return $number;
}
$number = 8.5;
echo roundOneUp($number);
?>
2. Example:
Input:
Input number: 8.2 Input number: 8.8
Output:
Output: 9 Output: 9