I have this php
<?php echo round($price, 2); ?>
and the $price
maybe 1.0000
i want 1.00
but i get only 1
any ideas
The ceil() function rounds a number UP to the nearest integer, if necessary. Tip: To round a number DOWN to the nearest integer, look at the floor() function. Tip: To round a floating-point number, look at the round() function.
echo round($fakecount * 100 / $totalcount); You are calculating $fakecount / $totalcount , which will be a number between 0 and 1, then you round that, so you get either 0 or 1, then you multiply by 100, giving either 0 or 100 for your percentage.
number_format works:
echo number_format($price, 2);
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