How to modify this code to remove everything from a given string exept numbers (already there) AND strings: “.”, “k “, “B “, and “M “?
What Im doing is parsing prices given in: 123k, 124.7B, 20M
preg_replace("/\D/", "", "<td>Cost: 20b $, Sell for: 139k $</td>" );
This should do the trick (as defined in question):
I think a preg_match may be better, especially if there is more than one number in your string (as in your example):
All numbers should then be nicely separated in the
$matcharray.