Right now I have:
printf('Rating: %.2F', $rating);
which prints like:
4.00
How can I show the leading zero, only if there is something to show after it?
For example:
printf("Rating: %g\n", 4.00);
printf("Rating: %g\n", 4.20);
printf("Rating: %g\n", 4.02);
prints
Rating: 4
Rating: 4.2
Rating: 4.02
So will printing the values without printf
demo
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