Get out of the tank and special tanks to get the number


I have a JSON part of my code which saves to the database like so:

 Bare Filter - £200.00

But I want to know how to strip everything out and just get the number so it's 20000 for example.

Can this be done?

I'm guessing str_replace() might be good, but not sure how to use it to achieve what I need.

$str = preg_replace('/[^0-9]+/', '', $str);

should leave just the numbers.

Then you could convert the string to a number by doing

$number = (int)$str;