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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 07:32:06  来源:igfitidea点击:

How to remove dots from numbers?

phpmysqlformattingnumbers

提问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

回答by Vahid Farahmand

You can use str_replace like this:

您可以像这样使用 str_replace :

$var1 = "10.000";
$var1 = str_replace(".", "", $var1);

more info about function is here

有关功能的更多信息在这里