Michael Jackson Michael Jackson - 1 year ago 79
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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download