I just posted this question link text about 5 minutes ago and I forgot to mention that the format was like this
"$2,090.99 "
I need the final value like
"209099"
Striping the final extra space and getting rid of any other punctuation in the money value with php so i can st开发者_StackOverflow社区ore into a mysql decimal 10,2
You can use a regular expression to replace everything that is not a digit:
$output = preg_replace('/\D/', '', $str);
\D
is equivalent to [^\d]
that is equivalent to [^0-9]
.
You might be better off using PHP 5.3's MessageFormatter
, Locale
and Intl
classes if you'll be handling different locales and currency formats. The msgfmt_parse()
method might just be what you need.
精彩评论