Moin,
sorry ich bin wirklich kein Programmierer. Ich habe es versucht ohne slashes und auch 1:1 Deinen Code zu übernhmen. Nach wie vor werden die umlaute einfach weggeschluckt.
Also so: anstatt künstlich, steht knstlich.
Woran kann das liegen, bzw. wie bekomme ich das hin ? Eigenartigerweise werden die Titel und auch meta-description richtig umgesetzt, nur bei den keywords, da werden Sonderzeichen verschluckt.
Der ganze block mit den Keywords lautet so:
Code: Alles auswählen
function get_keywords () {
if ($this->contents === false) return '';
$onew_arr = $this->parse_words();
$twow_arr = $this->parse_2words();
$thrw_arr = $this->parse_3words();
// remove 2-word phrases if same single words exist
if ($onew_arr !== false && $twow_arr !== false) {
$cnt = count($onew_arr);
for ($i = 0; $i < $cnt-1; $i++) {
foreach ($twow_arr as $key => $phrase) {
if ($onew_arr[$i] .' '. $onew_arr[$i+1] === $phrase) unset($twow_arr[$key]);
}
}
}
// remove 3-word phrases if same single words exist
if ($onew_arr !== false && $thrw_arr !== false) {
$cnt = count($onew_arr);
for ($i = 0; $i < $cnt-2; $i++) {
foreach ($thrw_arr as $key => $phrase) {
if ($onew_arr[$i] .' '. $onew_arr[$i+1] .' '. $onew_arr[$i+2] === $phrase) unset($thrw_arr[$key]);
}
}
}
// remove duplicate ENGLISH plural words
if ($this->lang == 'en') {
if ($onew_arr !== false) {
$cnt = count($onew_arr);
for ($i = 0; $i < $cnt-1; $i++) {
for ($j = $i+1; $j < $cnt; $j++) {
if (array_key_exists($i, $onew_arr) && array_key_exists($j, $onew_arr)) {
if ($onew_arr[$i].'s' == $onew_arr[$j]) unset($onew_arr[$j]);
if (array_key_exists($j, $onew_arr)) {
if ($onew_arr[$i] == $onew_arr[$j].'s') unset($onew_arr[$i]);
}
}
}
}
}
}
// ready for output - implode arrays
if ($onew_arr !== false) {$onew_kw = implode(',', $onew_arr) .',';}
else {$onew_kw = '';}
if ($twow_arr !== false) {$twow_kw = implode(',', $twow_arr) .',';}
else {$twow_kw = '';}
if ($thrw_arr !== false) {$thrw_kw = implode(',', $thrw_arr) .',';}
else {$thrw_kw = '';}
$keywords = $onew_kw . $twow_kw . $thrw_kw;
return rtrim($keywords, ',');
}
///////////////////////////////////////////////////////////////////////////////////////
function process_text ($str) {
if (preg_match('/^\s*$/', $str)) return false;
// strip HTML
$str = $this->html2txt($str);
//convert all characters to lower case
$str = mb_strtolower($str, $this->encoding);
// some cleanup
$str = ' '. $str .' '; // pad that is necessary
$str = preg_replace('#\ [a-z]{1,2}\ #i', ' ', $str); // remove 2 letter words and numbers
$str = preg_replace('#[0-9\,\.:]#', '', $str); // remove numerals, including commas and dots that are part of the numeral
$str = preg_replace("/([a-z]{2,})'s/", '\\1', $str); // remove only the 's (as in mother's)
$str = str_replace('-', ' ', $str); // remove hyphens (-)
Ergänzend dazu: überall ist UTF-8 angegeben. weiss nicht ob das eine Auswirkung hat. Bin leider nur User.