Posted By

ginoplusio on 02/04/10


Tagged

php html code clean tidy


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

kanampo
ginoplusio
redstorm
Ruggio


How to fix dirty HTML code with PHP


 / Published in: PHP
 

URL: http://www.barattalo.it/html-fixer/

This PHP class lets you clean and repair html code. WHAT IT DOES: delete closed tags without their opening tag, fix open tag without close, closing them automatically, check bad nesting and fix them, fix bad quotes in attributes, merge different styles attributes in the same tag, remove html comments, remove empty tags and more bad tags.

  1. /*
  2.   download the class from:
  3.   http://www.barattalo.it/html-fixer/
  4. */
  5.  
  6. $dirty_html = ".....bad html here......";
  7.  
  8. $a = new HtmlFixer();
  9. $clean_html = $a->getFixedHtml($dirty_html);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: redstorm on February 21, 2010

thank you, very useful

You need to login to post a comment.