This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question$dollar_amount_purchased = $dollar_amount_purchased + "0";
I tr开发者_Python百科ied the above code but it's not working. How am I supposed to do this in php?
http://php.net/manual/en/function.money-format.php
You should have a look at http://php.net/manual/en/function.number-format.php
Format numbers for display with number_format
. The first parameter is how many decimal places you want to show. If you specify 2 and the number does not have a tenths or hundredths place, it'll get padded with 0s automatically.
echo '$' . number_format($dollar_amount_purchased, 2, '.', ',');
精彩评论