PHP:不格式化的钱 [英] PHP: unformat money
本文介绍了PHP:不格式化的钱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
75,25€
,除 parsefloat(str_replace(', ','。',$ var))
? 我希望这取决于当前的网站语言,有时逗号可以用点代替。
解决方案
您可以使用
手册中的例子:
$ $ $ $ $ $ $格式化器=新NumberFormatter(' de_DE',NumberFormatter :: CURRENCY);
var_dump($ formatter-> parseCurrency(75,25€,$ curr));
给出: float(75.25)
p>
Is there a way to get the float value of a string like this: 75,25 €
, other than parsefloat(str_replace(',', '.', $var))
?
I want this to be dependent on the current site language, and sometimes the comma could be replaced by dot.
解决方案
You can use
Example from Manual:
$formatter = new NumberFormatter('de_DE', NumberFormatter::CURRENCY);
var_dump($formatter->parseCurrency("75,25 €", $curr));
gives: float(75.25)
Note that the intl extension is not enabled by default. Please refer to the Installation Instructions.
这篇关于PHP:不格式化的钱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文