1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP my turn for help please with php tidy

Discussion in 'Web Development' started by bmcoll3278, Sep 10, 2009.

  1. bmcoll3278

    bmcoll3278 New Member

    Hey guys I am building a page to validate html using php tidy

    I have it working fine but I want to format the repaired output with
    indents to make it look good and I cant figure it out. any ideas would be great here is the code I am using

    Code:
    <?php
    
    $file= $_POST['file'];
    
    
    $tidy = tidy_parse_string($file);
    $tidy->_error_count;
    
    
        echo "The following errors were detected:<br>";
        
    
    preg_match_all('/^(?:line (\d+) column (\d+) - )?(\S+): (?:\[((?:\d+\.?){4})]:)
    ?(.*?)$/m', $tidy->errorBuffer, $tidy_errors, PREG_SET_ORDER);
    
    $malestr = str_replace("line","\nline:",$tidy->errorBuffer);
    
    $article1=nl2br(htmlentities($malestr));
    echo "$article1<br>";
    
    $tidy->CleanRepair();
      
    echo"<textarea cols=\"80\"rows=\"30\">$tidy</textarea>";
    ?>
     
  2. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

  3. bmcoll3278

    bmcoll3278 New Member

    LOL

    I did figure it out though.

    It cleans up code nice I will post a link when it is looking good. Right now I used a page from my back pain articles section for a template so it looks goofy untill I change the other content.