PHP – Replace accents with their counterparts.

A small function to replace the character accented their pendants without.

function normalize_str ($str)
{
$invalid ' array,'' 'S', '''s', ''Dj', '''Dj', ''Z', ''Z', ''Z', ''Z', ''Z', ''Z', ''Z', ''Z', ''Z', ''Z', 'Z',
'C', ''C', ''C', ''C', ''C', ''A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
'EA', ''A', ''A', ''A', ''C', ''E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E',
'I', 'I', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O',
'O', 'OE', 'O', 'O', '''U', 'U', ''U', ''U', ''EU', 'EU', '''''''Y',
''B', '''ss', 'to''a', ''a', ''a', ''a',', 'a', 'a', 'a'a', ''a', ''a',',
''a', '''c', '''e', 'e', ''e', '''e', ''e', '''e', '''i', '''i', '''i',
'î''i', 'i'ie', 'o', '''''n', ''o', 'o', 'o', 'o'', 'o'', 'o'o', 'O'o', 'O'o',
'O'o', 'o', 'ù''u', ''''u', '''''u', '''''u', '''i', ''''y', ''''''''''''''
'''y', ''R', ''r', ''''r'' ''' ''''' '''''''' '''' ''''' ' ' ' ' '
"'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""" """"-" "-" """ """""""""""""""
 
$str - str_replace ($invalid array_keys), array_values $invalid, $str);
 
return $str;
}
Publicités

Leave a Reply