As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center获取指导。




7年前关闭。





我有两个数字类型的字符串,但结果出了错。

$totalamount='41,305.33';
$normalamount='999.72';
echo $total=$totalamount-$normalamount;


还有其他方法可以解决或使用我自己的代码发布。

最佳答案

您由于','字符而输入了错误的值,只需将其删除...

$totalamount='41,305.33';
$normalamount='999.72';
echo (double)str_replace(',','',$totalamount)-
     (double)str_replace(',','',$normalamount);

10-06 08:19