I would like to display £ 2.00 instead of £ 2 or £ 3.50 instead of £ 3.5 .
These numbers say it priceis defined as DOUBLEin a MySQL database. How to get MySQL or PHP to display two decimal places?
price
DOUBLE
Many thanks!
Try the following:
echo number_format ($price, 2);
For MySQL you can use the function format:
format
SELECT FORMAT(1.2345, 2);
He will return 1.23
For PHP you can use in a number_formatsimilar way:
number_format
echo number_format(1.2345, 2);
Also stamp 1.23
number_format money_format !
money_format
, .
, , DOUBLE - , .
, DOUBLE ; , . , , , . MySQL , DECIMAL, (.. ) .
DECIMAL