How do I convert output of number_format back to numbers in PHP?

后端 未结 9 1516
星月不相逢
星月不相逢 2020-11-27 16:47

PHP can\'t recognize 1,200.00(generated by number_format) but only 1200.00,

What\'s the general solution for this problem?

9条回答
  •  醉梦人生
    2020-11-27 17:08

    You could do $num = (float) str_replace(',', '', $num); Basically, just get rid of the commas, and then cast it as a numeric type (float or int).

提交回复
热议问题