How to remove redundant
tags from HTML code using PHP?

前端 未结 5 1594
孤街浪徒
孤街浪徒 2021-01-14 00:52

I\'m parsing some messy HTML code with PHP in which there are some redundant
tags and I would like to clean them up a bit. For instance:


&
5条回答
  •  孤城傲影
    2021-01-14 01:25

    This should work, using minimum specifier:

    preg_replace('/([\s]*){3,}/', '

    ', $multibreaks);

    Should match appalling



    constructions too.

提交回复
热议问题