/**
* 删除指定标签
* @param array $tags 删除的标签
* @param string $str html字符串
* @param bool $type 是否保留标签的内容
* @return mixed
* @usage
* $str = 'Hello</p><p><img src="http://www.baidu.com" /></b><Video>';
*
* // echo strip_tags($str, '<img');
* echo $this->stripHtmlTags(array('b','p'),$str,true);
*/
public static function stripHtmlTags($str,$tags=['p','b'], $content=true)
{
$html = [];
if($content){
foreach ($tags as $tag) {
$html[] = "/(<(?:\/" .$tag. "|" .$tag. ")[^>]*>)/is";
}
}else{
foreach ($tags as $tag) {
$html[] = '/<' .$tag. '.*?>[\s|\S]*?<\/' .$tag. '>/is';
$html[] = '/<' .$tag. '.*?>/is';
}
}
$data = preg_replace($html, '', $str);
return $data;
}