This function strips tags by any identifier without regexp, and without heavy XML parsing. As long as the tag looks exactly the same in source-code it works.
Source code viewer
/** * Strip tags by any identifier without regexp, and without heavy XML parsing. * * @param string $html Input HTML * @param string $tag Tag that is removed, example: <span class="some_class"> * @param string $tag_close Closing of tag, example: </span> * @param string $tag_family Tag family, example: <span * @param bool $del_children Will it remove tag and it's ending or everything between the tag aswell * @return Processed HTML */ function strip_given($html, $tag = '<div>', $tag_close = '</div>', $tag_family = '<div', $del_children = TRUE) { $p1 = -1; $p2 = 0; $level = 1; $p2 = $p1; $continue = true; while ($continue) { if ($p2 === false) { $continue = false; $p2 = false; } else { $level = $level -1; if ($level+$n<=0) $continue = false; } } if ($p2 !== false) { // remove tag and its ending if($del_children === FALSE) { } // delete tag contents aswell else { } } } return $html; } //------------------------------------------------------------------------------------------------------------------ /** * Strip tags with regex and without heavy XML parsing. * * @param string $str Input HTML * @param string $tags Tag that is removed, example: span class="some_class" * @param bool $stripContent Strip contesnt aswell * @return Processed HTML */ function strip_given($str, $tags, $stripContent = false) { $content = ''; } foreach ($tags as $tag) { if ($stripContent) $content = '(.+</'.$tag.'(>|\s[^>]*>)|)'; } return $str; }Programming Language: PHP