Strip everything but numbers and dots
Posted: Thu Mar 06, 2008 4:08 pm
I'm making a form which lets the user insert a price in any currency. I want the price stored as a float. How do I strip all characters expect numbers and decimal points?
I have the following code:
The problem is this also strips the decimal point.
I know how to strip an individual currency symbol, but the users could be using any currency so I'd like to just strip everything that isn't part of the float.
I have the following code:
Code: Select all
$price = preg_replace("/\D/", "",$_GET[price]);
I know how to strip an individual currency symbol, but the users could be using any currency so I'd like to just strip everything that isn't part of the float.