To round decimals upwards:
1 2 3 4 |
function round_up ( $value, $precision ) { $pow = pow ( 10, $precision ); return ( ceil ( $pow * $value ) + ceil ( $pow * $value - ceil ( $pow * $value ) ) ) / $pow; } |
For example:
1 |
echo round_up(100.243421,2) |
gives the result
1 |
100.25 |
Source: https://stackoverflow.com/questions/8239600/rounding-up-to-the-second-decimal-place