How can I format a price to two decimal places?
16,082
I believe you could use the code below:
$numberformatted = number_format($number, 2, '.', '');
More information: http://php.net/manual/en/function.number-format.php
Hope that helps.
Author by
Efficient Trade Ltd
Hello, I am a young New Zealand entrepreneur seeking to complete a complex trade website. Any help would be much appreciated!!
Updated on November 21, 2022Comments
-
Efficient Trade Ltd over 1 year
I was having trouble displaying some prices on my website in currency format (2 decimal places). Instead the values were being displayed at 4 decimal places.
Someone edited my original question and made it look terrible which made this post get negative rep!! :(.
Anyways, the answer is described below. Basically insert a function to my php variable.
-
Efficient Trade Ltd about 12 yearsThanks man, I used as follows: $MOQ_Unit_Price_formatted = number_format($MOQ_Unit_Price, 2, '.', ''); $BPQ_Unit_Price_formatted = number_format($BPQ_Unit_Price, 2, '.', '');