wondering how I can replace all special chars on my string like: hello this is a test!
I’ve wrote this code:
$text = preg_replace("/[^A-Za-z0-9]/", ' ', $text);
This works need more flexibility to allow special chars like áéíóú... and remove only certain chars like: :!"#$%&/()=?¿¡…
Any ideas?
Use
$text = preg_replace("/[^\p{L}\p{N}]/u", ' ', $text);This will match all characters that are not letters or numbers and will treat Unicode letters appropriately.