function strip_defined_tags($str, $tags, $stripContent = false) {
$content = "";
if (!is_array($tags)) {
$tags = (strpos($str, ">") !== false ? explode(">", str_replace("<", "", $tags)) : array($tags));
if(end($tags) == "") array_pop($tags);
}
foreach($tags as $tag) {
if ($stripContent) {
$content = "(.+|\s[^>]*>)|)";
$str = preg_replace("#|\s[^>]*>)".$content."#is", "", $str);
}
return $str;
}
$content = "";
if (!is_array($tags)) {
$tags = (strpos($str, ">") !== false ? explode(">", str_replace("<", "", $tags)) : array($tags));
if(end($tags) == "") array_pop($tags);
}
foreach($tags as $tag) {
if ($stripContent) {
$content = "(.+|\s[^>]*>)|)";
$str = preg_replace("#|\s[^>]*>)".$content."#is", "", $str);
}
return $str;
}
منبع: