- function _strip_tags($str, $tags, $clear = false)
- {//去除指定html标签,$clear设为true时同时清除标签内容
- $tagsArr = explode('<', $tags);
- unset($tagsArr[0]);
- foreach ($tagsArr as $tag) {
- $tag = trim($tag, '>');
- if($clear) {
- $p[] = "/<".$tag.".*<\\/".$tag.">/i";
- } else {
- $p[] = "/(<(?:\\/".$tag."|".$tag.")[^>]*>)/i";
- }
- }
- $return_str = preg_replace($p,"",$str);
- return $return_str;
- }
- //该片段来自于http://www.codesnippet.cn/detail/200120148564.html
来源: http://www.codesnippet.cn/detail/200120148564.html