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;
精彩评论