Tidy up your html with php

By using the Tidy php class, you can format your html output.

Below is an example.

<?php
$html = "<html><head><title>a title</title></head><body>here is the body</body></html>";
$config = array('indent'=>true, 'output-xml'=>true, 'input-xml'=>true, 'wrap'=>'1000', 'indent-spaces'=>'8');
$tidy = new tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
$html = tidy_get_output($tidy);
print($html);
?>

The output will be nicely formatted and indented. Indented to 8 spaces.

References

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.