Remove whitespace from HTML

前端 未结 15 1781
花落未央
花落未央 2020-12-28 14:25

I have HTML code like:

15条回答
  •  时光取名叫无心
    2020-12-28 14:38

    $html = preg_replace('~>\s*\n\s*<~', '><', $html);
    

    I'm thinking that this is the solution to the Hello world problem. The idea is to remove whitespace only when there's a new line. It will work for common HTML syntax which is:

提交回复
热议问题