In PHP I have decimal numbers that may or may not have trailing zeros.
For example
1
1.1
43.87
How do I make sure that all these numbers have exactly two decimal places like this:
1.00
1.10
43.87
You should use number_format():
number_format(1.1, 2);
来源:https://stackoverflow.com/questions/18898638/php-format-number-to-have-always-have-2-decimal-places