开发者

Making the money value with only numbers

开发者 https://www.devze.com 2023-01-24 02:06 出处:网络
I just posted this question link text about 5 minutes ago and I forgot to mention that the format was like this

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消