3

Possible Duplicate:
PHP “pretty print” HTML (not Tidy)

Lets say I have php var contains this string :

 <html><head><title>Page title</title></head><body><div>content here</div></body></html>

How I can to format this html code with php ? When I say format I mean to add line breaks and add tabs to this code to be like :

<html>
    <head>
        <title>Page title</title>
    </head>
    <body>
        content here
    </body>
</html>

I know there is tidy extension to php , but I need an alternative solution for that.

Thanks.

Community
  • 1
  • 1
  • 6
    "but I need an alternative solution" - because of? – Marcin Orlowski Dec 22 '12 at 14:33
  • you can get an answer here http://stackoverflow.com/questions/6516318/auto-format-html-php-with-line-breaks-and-tabs – ogres Dec 22 '12 at 14:35
  • And http://stackoverflow.com/questions/6891416/an-alternative-to-php-tidy – Tiger-222 Dec 22 '12 at 14:36
  • What is the difference between the contents of the `

    ` tag and that of the `

    ` tag? Let aside a script, how can a person know why the former is stuck inside the tags whereas the latter is located in a separate line and tabbed at first place? Also, if you're sure it's gonna be strict html then I would suggest you to parse it as XML instead.

    – inhan Dec 22 '12 at 14:57

0 Answers0