开发者

PHP - Finish HTML tags that haven't been closed?

Let's say that I get an input of something like:

<strong>bunch <em>开发者_C百科of</em> <span>random text

I want code to be able to take this string and turn it into:

<strong>bunch <em>of</em> <span>random text</span></strong>


Probably the first place to look is the Tidy extension

$html = "<strong>bunch <em>of</em> <span>random text";
$tidy = tidy_parse_string($html, array('clean' => true, 'show-body-only' => true));
$tidy->cleanRepair();
echo $tidy;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜