Jump to content
php.lv forumi

teksta filtreeshana ar preg_replace


Analgiins

Recommended Posts

nu pats uztaisiiju shitaatu scriptu, tjip masiivs ar visiem tagiem:

$all_tags = array (
"!DOCTYPE",
"a",
"abbr",
"acronym"
... visus jau neraxtiishu
...
"var",
"xmp");

atljautie tagi:

$allowed_tags = array (
'b'
,'i'
,'u'
,'img'
,'br'
);

filtreejam:

foreach ($all_tags as $tag) {
   if (!in_array($tag, $allowed_tags))
       $text = preg_replace("'<".$tag."[^>]*?>.*?</".$tag.">'si", "", $text);
}

Nu viss straadaa, tachu neracionalitaate pashaa pilniibaa. Izsakiet savus viedokljus.

Link to comment
Share on other sites

×
×
  • Create New...