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));
精彩评论