开发者

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

开发者 https://www.devze.com 2023-03-28 10:12 出处:网络
Let\'s say that I get an input of something like: <strong>bunch <em>开发者_C百科of</em> <span>random text

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

精彩评论

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