Posted By

stancell on 02/09/09


Tagged


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

fackz
jfherring
bryandease
pezland
vali29
ginoplusio
nb109


Clean up HTML with Tidy


 / Published in: PHP
 

Cleans up HTML using tidy. Returns only part. Set show-body-only to false if you want full document.

  1. function tidy_html($html)
  2. {
  3. $tidy_config = array(
  4. 'clean' => true,
  5. 'output-xhtml' => true,
  6. 'show-body-only' => true,
  7. 'word-2000' => true,
  8. 'show-body-only' => true,
  9. );
  10.  
  11. $tidy = new tidy();
  12. $tidy->parseString($html, $tidy_config, 'utf8');
  13. $tidy->cleanRepair();
  14. return tidy_get_output($tidy);
  15. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: ginoplusio on February 5, 2010

If you can't activate tidy module, use this: html fixer

You need to login to post a comment.