-
- //解决strip_tags的bug
- function fixtags ($text) {
- $text = htmlspecialchars($text);
- $text = preg_replace("/"/", ""\"", $text);
- $tags = "/<(!|)(\/|)(\w*)(\ |)(\w*)([\\\=]*)(?|(\")\""\"|)(?|(.*)?"(\")|)([\ ]?)(\/|)>/i";
- $replacement = "<$1$2$3$4$5$6$7$8$9$10$11>";
- $text = preg_replace($tags, $replacement, $text);
- $text = preg_replace("/=\"\"/", "=", $text);
- $text = preg_replace("/"\"/", "\"", $text);
- return $text;
- }
复制代码
使用方法:
-
- strip_tags(fixtags($string), '
');
复制代码
|