开发者

How can I strip all html using a preg_replace?

strip_tags only catches tags that have a beginning and end开发者_StackOverflow社区 tag. With the strings I'm working with it's causing issues and I need to removed all HTML tags.


If you want to clean some HTML, I would suggest using a real HTML parser, like HTMLPurifier.

Generally speaking, trying to manipulate HTML with regex tends to end badly...


<?php

$html = '<p>Lorem ipsum dolor <br>sit amet, <br />consectetur adipisicing elit</p>';
echo strip_tags($html);

?>

... prints:

Lorem ipsum dolor sit amet, consectetur adipisicing elit

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜