PHP temiz işlevi düzgün çalışmıyor

0 Cevap

Ben veritabanı içeriği yararlı URL'leri oluştururken yardımcı olacak bir proje için PHP temiz bir fonksiyon oluşturduk. "Benim Motörhead Albümleri" gibi bir cümle URL my-motoerhead-albümler olur böylece, herhangi bir boşluk ve özel karakterleri kaldırır. Ancak, doğru vb ö, ä, ü, gibi umlauts dönüştürmek değil gibi görünüyor, ve ben neden bilemiyorum.

İşte kod:

function clean($text) {
$text = trim($text);
$text = strtolower($text);
$code_entities_match = array(
' ',    '--',    '"',    '!',    '@',    '#',    '$',    '%',    '^',    '&',
'*',    '(',    ')',    '_',    '+',    '{',    '}',    '|',    ':',    '"',    
'<',    '>',    '?',    '[',    ']',    '\\',    ';',    "'",    ',',    '.',
'/',    '*',    '+',    '~',    '`',    '=',    '¡',    '¿',     '´', '%C2%B4', 
'ä',    'ö',    'ü',    'ß',    'å',    'á',    'à',
'ó',    'ò',    'ú',    'ù',    'í',    'é',    'è',    'ø', 'Þ', 'ð', '%C3%9E', '&thorn;'
);
$code_entities_replace = array(
'',    '-',    '',    '',    '',    '',    '', '',    '',    '',    
'',    '',    '',    '',    '',    '',    '',    '',    '',    '',
'',    '',    '',    '',    '',    '',    '',    '',    '',    '',    
'',    '',    '',    '',    '',    '',    '',    '',    '',    '',    
'ae',    'oe',    'ue',    'ss',    'aa',    'a',    'a',    'o',    'o',    'u',    'u',    'i',    'e',    'e',    'oe',    'th',    'th',    'th',    'th'
);
$text = str_replace($code_entities_match, $code_entities_replace, $text);
return $text;

}

0 Cevap