ich brauche eine Funktion, die mir aus einem String alle HTML-Tags entfernt, ausgenommen einiger Tags, die ich explizit zulasse. Nun habe ich folgende Funktion gefunden, welche jedoch nur alle definierten Tags entfernt:
Code: Alles auswählen
function soft_strip_tags($text, $tags = array('br', 'ul', 'li', 'strong')) {
$args = func_get_args();
$text = array_shift($args);
$tags = func_num_args() > 2 ? array_diff($args,array($text)) : (array)$tags;
foreach ($tags as $tag) {
if(preg_match_all('/<'.$tag.'[^>]*>(.*)<\/'.$tag.'>/iU', $text, $found)){
$text = str_replace($found[0],$found[1],$text);
}
}
return $text;
}
Vielen Dank schonmal
