ciauz, grazie della risposta...
è che a seconda dei permessi dell'utente può utilizzare html o bbcode...
cmq ho trovato questa funzione...e funge perfettamente...l'unico problema è che nn accetta i tag dell'xhtml
ad esempio 'br /'
qualcuno sa come modificare la regular expression?
Codice PHP:
function strip_tags_except($text, $allowed_tags, $strip=TRUE) {
// allowing the user to specify the tags to strip, she can specify the tags to allow and strip all others. The third parameter, $strip, when TRUE removes "<" and ">" from the string and when FALSE converts them to "<" and ">" respectively.
if (!is_array($allowed_tags))
return $text;
if (!count($allowed_tags))
return $text;
$open = $strip ? '' : '<';
$close = $strip ? '' : '>';
preg_match_all('!<\s*(/)?\s*([a-zA-Z]+)[^>]*>!',
$text, $all_tags);
array_shift($all_tags);
$slashes = $all_tags[0];
$all_tags = $all_tags[1];
foreach ($all_tags as $i => $tag) {
if (in_array($tag, $allowed_tags))
continue;
$text =
preg_replace('!<(\s*' . $slashes[$i] . '\s*' .
$tag . '[^>]*)>!', $open . '$1' . $close,
$text);
}
return $text;
}
ciauzzz