PHP preg_replace question?

I have this to get rid of everything except numbers

$string2 = preg_replace(“/[^0-9]/”,””,$string);

But I also want it to keep – and .

Also can someone please explain how it works, I really don’t get it.

✅ Answers

? Best Answer

  • Using preg_replace in PHP: http://php.net/manual/en/function.preg-r…
  • Leave a Comment