[英]In PHP how do you format a number as currency handling cases such as 10 cents equaling “$.1”;
我目前正在:
$totalBill = number_format($totalBill, 2);
$totalBill = '$'.$totalBill;
尽管总计为10美分,但这不能处理案件。 它返回我不想要的“ $ 0.1”。 有谁有更好的方法?
$totalBill = sprintf('$%.2f',$totalBill);
您可能需要money_format()
代替
使用PHP的money_format函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.