Skip to content
Advertisement

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

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

What’s the general solution for this problem?

Advertisement

Answer

You could remove any character that is not a digit or a decimal point and parse that with floatval:

JavaScript

And if the number has not . as decimal point:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement