无法计算出PHP str_replace()以删除逗号 [英] Cannot work out a php str_replace() to remove comma

查看:77
本文介绍了无法计算出PHP str_replace()以删除逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个PHP项目中,我有:

In a PHP project, I have:

$string = "1,555";

str_replace(',', '', $string);
echo $string; //is still 1,555

str_replace不会删除逗号.如果我是var_dump.我得到string(5) "1,555"

str_replace does not remove the comma. If I var_dump. I get string(5) "1,555"

有什么想法吗?我只需要删除逗号即可进行计算.

Any ideas? I just simply need to remove the commas so I can compute.

推荐答案

$string = str_replace(',', '', $string);

这篇关于无法计算出PHP str_replace()以删除逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆