用户可以以下列格式输入值:
现在,我需要返回使用两个小数点(,)形成的值。当我使用:
Number_format(美元请求->金额,2,'‘)
并使用"1,00“作为输入,我得到以下错误:
Notice: A non well formed numeric value encountered什么是解决这一问题的最佳方法,并且仍然能够处理所有三种类型的输入?
下面是一个简短的例子:
input of user:|output:
1.00 1,00
1 1,00
1,51 1,51发布于 2016-03-10 17:49:17
下列措施应能发挥作用:
$request->amount = str_replace(",", ".", $request->amount);
number_format($request->amount, 2, ',','');发布于 2016-03-10 17:25:28
试试这个:
number_format((int)$request->amount, 2, ',','');https://stackoverflow.com/questions/35923007
复制相似问题