I have a value like this:
$value = 2.3333333333;
and I want to round up this value into like this:
$value = 2.35;
I already tried round, ceil and etc but the result is not what I expected.
Please anyone help.
Thanks
Taking your question literally, this will do it:
$value = (round($original_value / 0.05, 0)) * 0.05
i.e. will round to the nearest 0.05.
If, for some reason, you want to always round up to 0.05, use
$value = (round(($original_value + 0.025) / 0.05, 0)) * 0.05
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