Strip commas and spaces

Hey everyone,

Is there a native PHP function that strips commas, dots and spaces from a number?

for example the number 1,000.25 should become 1000.25

many thanks

Hmm this doesn’t seem to work. I have a variable “fl_area” that produces a text with a comma 1,025 but the function to convert it to feet needs the comma to be removed for the conversion to be successful.

metersToFeetInches( number_format(get_field( "fl_area" ), 2, '.', '') );

Ah I see, try to make it a habit to store your “numbers” as such, without commas, you can always format then with them using number_format later.

$string = '1,600.45';
$number = (double)str_replace(",", "", $string);

metersToFeetInches((double)str_replace(",", "", $fl_area));