function stripSingleEndedTag($content, $allowed = array()){
(array)$allowed;
$singletags = array('<meta>','<img>','<input>','<hr>','<br>','<link>','<isindex>','<base>','<meta>','<nextid>','<bork>');
$stripthese = arrayfilterout ($singletags, $allowed);
$stripthese = str_replace(array('<','>'),'',$stripthese);
$pattern = '/<('. implode('|', $stripthese) .')[^>]+\>/i';
$content = preg_replace($pattern, "", $content);
return $content;
}
我在这里得到的将去掉一个单尾标签,<bork />
但前提是在“bork”之后和“>”之前有一些字符。 <bork >
并被<bork/>
剥离,但不是<bork>
顺便说一句,不能使用strip_tags()
。