开发者

How convert number_formated output to numbers?

i 开发者_StackOverflow中文版want to convert number_formated output like 129,888.0 to 1298880 to return function when edit from db.

Thank you


If $string is the number_formatted output, then this will turn it back to a number by removing any non-numeric characters.

$number = preg_replace('/[^\d]/', null, $string);

As an aside, you should really store things un-formatted and just format them when you want to display them.


 $numstr = "100,000,000.75";
 $num = doubleval(str_replace(",",".",$mynumstr));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜