PHP FUNCTION TO CONVERT ACCENTED CHARACTERS TO THEIR NON-ACCENTED EQUIVALANT

Saw that someone was using a simple preg_replace() with Alpha Numeric only regex to deal with an Umlauted O in a string and thought I’d post a slightly better way of doing it. There’s always better ways, we’ve just got to share them, so here I go…

Remove greek accents

function convert_greek_accents($str) {
    $unwanted_array = array('Ά' => 'Α', 'ά' => 'α', 'Έ' => 'Ε', 'έ' => 'ε', 'Ή' => 'Η', 'ή' => 'η', 'Ί' => 'Ι', 'ί' => 'ι', 'Ό' => 'Ο', 'ό' => 'ο', 'Ύ' => 'Υ', 'ύ' => 'υ', 'Ώ' => 'Ω', 'ώ' => 'ω', 'ϊ' => 'ι','ϋ' => 'υ', 'Ϊ' => 'ι', 'Ϋ' => 'Υ');
    $str = strtr($str, $unwanted_array);
    return $str;
}

Leave a comment