<?php
function clean_tidy($what_to_clean, $tidy_config='' ) {
  
    $config = array(
        'show-body-only' => false,
        'clean' => true,
        'char-encoding' => 'iso-8859-1',
        'add-xml-decl' => true,
        'add-xml-space' => true,
        'output-html' => true,
        'output-xml' => false,
        'output-xhtml' => false,
        'numeric-entities' => false,
        'ascii-chars' => false,
        'doctype' => 'strict',
        'bare' => true,
        'fix-uri' => true,
        'indent' => true,
        'indent-spaces' => 4,
        'tab-size' => 4,
        'wrap-attributes' => true,
        'wrap' => 0,
        'indent-attributes' => true,
        'join-classes' => false,
        'join-styles' => false,
        'enclose-block-text' => true,
        'fix-bad-comments' => true,
        'fix-backslash' => true,
        'replace-color' => false,
        'wrap-asp' => false,
        'wrap-jste' => false,
        'wrap-php' => false,
        'write-back' => true,
        'drop-proprietary-attributes' => false,
        'hide-comments' => false,
        'hide-endtags' => false,
        'literal-attributes' => false,
        'drop-empty-paras' => true,
        'enclose-text' => true,
        'quote-ampersand' => true,
        'quote-marks' => false,
        'quote-nbsp' => true,
        'vertical-space' => true,
        'wrap-script-literals' => false,
        'tidy-mark' => true,
        'merge-divs' => false,
        'repeated-attributes' => 'keep-last',
        'break-before-br' => true,
    );
  
    if( $tidy_config == '' ) {
        $tidy_config = &$config;
    }
  
    $tidy = new tidy();
    $out = $tidy->repairString($what_to_clean, $tidy_config);
    unset($tidy);
    unset($tidy_config);
    return($out);
}
?>