Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
990 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...