How to convert special characters to normal characters?

I am trying to convert characters like:

ë, ä, ï, ö, etc.

To normal characters like:

e, a, i, o, etc.

What is the best way to do this?
I’ve tried many things, like preg_replace and str_replace.

Can someone help me out?

— EDIT —

What I tried, was:

$ts = array("[À-Å]","Æ","Ç","[È-Ë]","/[Ì-Ï]/","/Ð/","/Ñ/","/[Ò-ÖØ]/","/×/","/[Ù-Ü]/","/[Ý-ß]/","/[à-å]/","/æ/","/ç/","/[è-ë]/","/[ì-ï]/","/ð/","/ñ/","/[ò-öø]/","/÷/","/[ù-ü]/","/[ý-ÿ]/");

$tn = array("A","AE","C","E","I","D","N","O","X","U","Y","a","ae","c","e","i","d","n","o","x","u","y");

$title = preg_replace($ts, $tn, $text);

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

try this .. works for me.

iconv('utf-8', 'ascii//TRANSLIT', $text);

Solution 2

i like stewies’ answer, but for completeness this works for me.

preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities($foo));

Solution 3

For example, it is create a simple readable URL from a content title:

function cleanurl($title) {
        return urlencode(strtolower(str_replace(" ","-",preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities($title)))));

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply