开发者

How convert number_formated output to numbers?

开发者 https://www.devze.com 2023-01-29 03:28 出处:网络
i 开发者_StackOverflow中文版want to convert number_formated output like 129,888.0 to 1298880 to return function when edit from db.

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

精彩评论

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