Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72560

Beautify HTML stored in a string on PHP

$
0
0

I have a string in variable $html that contains minified HTMl code, all in one line, like:

$html = '<body><div><p>hello</p><div></body>';

How do I beautify/pretty print the HTML so that my variable becomes like:

 $html = '<body>
             <div>
               <p>hello</p>
             <div>
          </body>';

I know the tidy extension is a possibility, but how can this be done without an extension.

EDIT: PLEASE read the question. I am not asking how to beautify HTML code via some external site. I am asking how to do it in PHP, specifically targeting the string variable.


Viewing all articles
Browse latest Browse all 72560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>