php 如何去除数字中的点?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14558343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove dots from numbers?
提问by user1632298
I have a form formatted with javascript, which makes numbers look like:
我有一个用 javascript 格式化的表单,它使数字看起来像:
10.000 or 2.300
10.000 或 2.300
<form>
<input type="text" name="price_1" value="2.300">
</form>
But i want to store them in mysql without dots. How to remove them?
但我想将它们存储在没有点的 mysql 中。如何删除它们?
mysql_query("INSERT INTO prices price_a='price_1' WHERE id ='price_id'");
I see money_format and number_format, but its just format the numbers dont remove anything.
我看到money_format 和number_format,但它只是格式化数字不会删除任何内容。
回答by Prasanth Bendra
Try this :
尝试这个 :
str_replace(".", "", $string);
回答by Edwin Alex
You can use str_replace()function.
您可以使用str_replace()功能。
echo str_replace(".", "", $value);
$value would be 10.000
$value 为 10.000

