PHP “pretty print” HTML (not Tidy)

后端 未结 3 462
耶瑟儿~
耶瑟儿~ 2020-11-29 04:53

I\'m using the DOM extension in PHP to build some HTML documents, and I want the output to be formatted nicely (with new lines and indentation) so that it\'s readable, howev

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 05:21

    You can use the code for the hl_tidy function of the htmLawed library.

    // indent using one tab per indent, with all HTML being within an imaginary div
    $out = hl_tidy($in, 't', 'div')
    

提交回复
热议问题