Go Back   Free website templates > Web Template Help > PHP and MySQL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Join now to share free website templates or post on the forum. If you have never been on a forum before read the FAQ. It's quick, easy and free to join!
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-11-2009, 04:24 AM
bmcoll3278's Avatar
Senior Member
 
Join Date: Jun 2009
Posts: 303
bmcoll3278 is on a distinguished road
Default my turn for help please with php tidy

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>";
?>
__________________
I hope to build a site with something for every body
www.bmcoll.com
Reply With Quote
  #2 (permalink)  
Old 09-11-2009, 10:28 AM
ishkey's Avatar
Moderator
 
Join Date: Aug 2007
Location: North GA USA
Posts: 1,776
ishkey will become famous soon enough
Default

Your the php expert, but here are some thoughts.
Try using CSS to format your Textarea element.
There is always the old trim() but your browser will collapse contiguous whitespace.
maybe these links will help - they are for cleaning up source code - but it gives you an idea.
http://www.vim.org/scripts/script.php?script_id=1120

http://www.bierkandt.org/beautify/
__________________

Consultant - Programmer - WebMaster
cleandeck - lawn mower undercoating
wilmargraphite - graphite lubricants
Reply With Quote
  #3 (permalink)  
Old 09-11-2009, 03:22 PM
bmcoll3278's Avatar
Senior Member
 
Join Date: Jun 2009
Posts: 303
bmcoll3278 is on a distinguished road
Default

Quote:
Your the php expert
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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 01:37 AM.



mouseover mouseover mouseover