ag3nt42 Posted June 27, 2008 Share Posted June 27, 2008 Hello again all, I'm trying to setup a website where the owner can edit a .txt file without having to know any code.. and I want to be able to pull in that txt file to a php page and format it for them. based on certain text characteristics like.. if there is a period toss in a <br /> tag ect... then directly display the newly formatted text on the webpage.. any ideas on how I could do that?? thankx alot, ag3nt Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 27, 2008 Author Share Posted June 27, 2008 no ideas? Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 27, 2008 Author Share Posted June 27, 2008 anyone feel free to jump in anytime here.. this is what I got so far.. <?php $file = fopen("../Editable/welcome.txt","r"); $p=0; while(! feof($file)) { $z=fgetc($file); if($z=='.') { echo($z); echo('<br />'); $p++; } else { echo($z); } if($p==5) { echo("<br /><br />"); $p=0; } } ?> this works pretty well. but its not perfect by far... Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 27, 2008 Author Share Posted June 27, 2008 this seems to work better then the last one <?php $file = fopen("../Editable/welcome.txt","r"); $p=0; while(! feof($file)) { $z=fgetc($file); if($z=='%'){echo('<br />');}else{echo($z);} if($z=='.'){$p++;} if($p==4){echo("<br /><br />");$p=0;} } ?> Quote Link to comment Share on other sites More sharing options...
Jabop Posted June 27, 2008 Share Posted June 27, 2008 I'm glad you found a solution. Good work. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 27, 2008 Author Share Posted June 27, 2008 I'm glad you found a solution. Good work. lol thanks, I was hoping for some help figuring out how I can do it better tho...like right now I can do either of those two ways... but if you put a period where a line doesn't end.. such as P.O. Box it will drop down a line at each period.. or for the second version.. I have to tell them to use a special character to go down a line.. which isn't kwl seems like there should be alot easier way to do this.. like somehow preserve whitespace... I tried using some CSS like white-space:pre; or normal; but neither works right. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 27, 2008 Author Share Posted June 27, 2008 here is the fix... <div class='welcometxt'> <pre style='word-wrap:break-word;'> <?php include('Editable/welcome.txt') ?> </pre> </div> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.