Simulator88
Simulator88

Reputation: 637

How to remove dots from numbers?

I have a form formatted with javascript, which makes numbers look like:

10.000 or 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_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.

Upvotes: 9

Views: 40032

Answers (3)

Prasanth Bendra
Prasanth Bendra

Reputation: 32760

Try this :

$string = str_replace(".", "", $string);

Upvotes: 31

Edwin Alex
Edwin Alex

Reputation: 5108

You can use str_replace() function.

echo str_replace(".", "", $value);

$value would be 10.000

Upvotes: 2

Vahid Farahmand
Vahid Farahmand

Reputation: 2558

You can use str_replace like this:

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

more info about function is here

Upvotes: 1

Related Questions