PHP replace all special characters

If you want to remove or replace all specials characters from a string, you can use the preg_replace() function.
It replace all characters that are not A-Z or a-z

$nom = preg_replace('#[^A-Za-z]+#i','', $nom);

Leave a Reply