I am looking to replace all characters in a string except letters, numbers, spaces and underscores.
Could someone please provide a example?
I normally use something like:
$string = preg_replace("/[^ \w]+/", "", $string);
That replaces all non-space and non-word characters with nothing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With