By calculating areas I have a number which I need to display in a strange way.
Always display 2 decimal places. Always round up the 2nd decimal place if the 3rd+ decimal places > 0.
Examples:
0.5 = 0.50
0.500003 = 0.51
0.96531 = 0.97
0.96231 = 0.97
0.8701 = 0.88
Is there a built in function to do this in PHP or do I need to write one?
To always round up you will want to use something like this:
$number = 0.8701;
echo ceil($number*100)/100;
// = 0.88
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With