Michael Jackson Michael Jackson - 11 months ago 54
PHP Question

Remove all special characters but keep dots and accents

I'm trying to remove all special characters from a string keeping dots and accents. I already got the accents working, how can I allow the dots?

My function.

function clean($string) {

return preg_replace('/[^\p{L}0-9\-]/u', ' ', $string);// Removes special chars.



Answer Source

Add a dot to your character group. /[^\p{LN}\-.]/u <-- see the dot