Jump to content

[SOLVED] autoformat text...


ag3nt42

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/112230-solved-autoformat-text/
Share on other sites

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...

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.