因此,在我的php文件中,我从注册表中请求价格。在html中,我想填写一个值2,50。所以我以为我会用str_replace(用“。”代替“,”),但是我也想用“”代替“€”。我不确定该怎么做。我尝试一次做1个,效果很好。我现在这里有一些代码:
我的PHP代码
$registration->reg_price = str_replace('€ ', '', $request->price);
$registration->save();
将为您提供任何帮助!
$registration->reg_price = str_replace(['€ ', ','], ['', '.'], $request->price);
$registration->reg_price = str_replace('€', '', $request->price);
$registration->reg_price = str_replace(',', '.', $registration->reg_price);
[str_replace
返回字符串,您可以在更新的字符串上应用字符串替换。