Jump to content

Using Text Files to Dynamically Edit a Page (word wrap)


DamienRoche

Recommended Posts

I have just begun learning how to use fopen() etc. etc. and have run into a little problem when calling the data from a .txt

 

The issue is that sometimes the data is not wrapped when I use divs, even specifying width. I figured CSS would take over the wrapping but it just isn't.

 

I have also tried using wordwrap() but I can't figure out how to make it wrap whole words to the next line.

 

$context3 = wordwrap($context2, 200, "-<br>\n");

 

This isn't really ideal in that I have to specify a character limit instead of pixels. But it will do if I can get the above function to work like I mentioned.

 

EDIT: I forgot to mention something very important. I am using a pre tag to preserve certain line breaks because without it, the text is a constant string. Is there an alternative in php? how can I control the behavior?

 

As always, I am very grateful for any help.

Thanks for the response. The issue is definitely not the css. I'm no beginner with css like php.

 

The issue is undoubtedly the < pre > tag. The whole point of it is to preserve the line breaks. But I want to modify how it behaves. Or possibly mimic it's behavior using php.

 

Does anyone know how the pre tag preserves line breaks or how I can, using php?

 

Thanks again.

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.