聘我网

新概念招聘3.0

PHP如何将number_format的输出结果转化回数字?

vote up0vote downstar

比如,1,200.00转化为1200.00PHP中有通用的解决方法不?

 

2 个答复

vote up0vote downcheck
function parse_number($number, $dec_point=null) {
    if (empty($dec_point)) {
        $locale = localeconv();
        $dec_point = $locale['decimal_point'];
    }
    return floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $number)));
}

如果PHP版本>=5.3,可以用numfmt_parse

链接
vote up0vote down

This is way betetr than a brick & mortar establishment.

链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.