Page 1 of 1

a simple php question i can't get answered anywhere.

Posted: Wed Dec 16, 2009 5:12 pm
by joegats916
Okay.. so like the title says, it's simple. At least, I think it's simple. Other people have answered this question with solutions that don't give me a result that I'm looking for so I will try to provide as much information as I can.

I'm designing a basic html website with PHP elements for a very specific purpose. The purpose is this... I'm setting up the page for someone who knows less about PHP and HTML then me, and I want it to be easy for them to make updates to the page without using any code. The solution that I felt was best was to setup a series of text files from which blocks of content on the page would come from. An example of this would be a welcome header followed by a php script which would draw a few paragraphs from a text file to fill the content below the welcome header.

By using the fread command, someone was able to teach me how to display text naturally from a website, the problem is, is that the text is losing the format it had in the text file. The specific format I'm concerned with is the paragraphs. Instead of neatly formatted paragraphs, the data is being displayed without any break. I'm trying to find a way for the information to retain it's paragraphed format without having to add any special code into the text file.

Another important element of the script is that I wont know how many paragraphs there will be in the text file. there may be one, two, five. and the amount of paragraphs may change when a new text file is uploaded to replace the last one as the website is updated.

If I've left any information out, please e-mail me at studiogipsy (at) gmail (dot) com or reply in the forum.

thank you

Re: a simple php question i can't get answered anywhere.

Posted: Wed Dec 16, 2009 5:36 pm
by AbraCadaver
I'm pretty sure that I understand what you're doing but some code examples would help. If by paragraph you mean blocks of text separated by linebreaks, then I would do this (no need to use fread()):

Code: Select all

$text = nl2br(file_get_contents('your_file.txt'));
// wherever you want to use it
echo $text;

Re: a simple php question i can't get answered anywhere.

Posted: Wed Dec 16, 2009 6:21 pm
by joegats916
YOUR F'ING BEAUTIFUL MAN. My own personal Jesus H.. I have been literally up all night trying to figure out this stupid code. It's like when i was 16 figuring out DOS.. anyway, thanks so much, you really saved me!

Re: a simple php question i can't get answered anywhere.

Posted: Wed Dec 16, 2009 9:01 pm
by daedalus__
lol its a simple concept but something you are going to have to implement yourself thats why you arent getting a good response. people do this all day with blogs and myspaces and whatever twitter. that's all people 'modifying html without any code'

but listen though be really careful with the text files. im curious about what the application is. you could be leaving some pretty big security holes. please dont just copy and paste that.