Cannot work out a php str_replace() to remove comma

馋奶兔 提交于 2019-12-04 01:26:52

问题


In a PHP project, I have:

$string = "1,555";

str_replace(',', '', $string);
echo $string; //is still 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.


回答1:


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


来源:https://stackoverflow.com/questions/11525560/cannot-work-out-a-php-str-replace-to-remove-comma

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!