如何将数字转换为显示美元和美分的字符串?
eg:
123.45 => '$123.45'
123.456 => '$123.46'
123 => '$123.00'
.13 => '$0.13'
.1 => '$0.10'
0 => '$0.00'
最佳答案
如果你只是想要一些简单的东西:
'$' . number_format($money, 2);
number_format()
https://stackoverflow.com/questions/294865/