假设我输入的内容如下:
<strong>bunch <em>of</em> <span>random text
我希望代码能够获取此字符串并将其转换为:
<strong>bunch <em>of</em> <span>random text</span></strong>
答案 0 :(得分:5)
可能首先要看的是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;