Large Amounts of Text

garrensilverwing

New Member
Messages
148
Reaction score
0
Points
0
Hey everyone,

I have more of a theoretical question this time. On my website I want to post large amounts of text and have the server create all the code necessary for it to display the way I have it already designed. For an example go to http://www.brianwallchess.net/emails/fox . Basically fit a certain amount of words on one page and all the run off goes onto another page and so on and so on and then its all displayed in an iframe with links connecting them. I already have the code to create a majority of the stuff necessary but i'm having trouble getting the text that I enter to format properly, does anyone have a theoretical way this can be done? I was thinking of doing like a character to line ratio but i cant get my mind to wrap around how it would work

thanks in advance

chris
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
Why don't you do a strpos() using the optional 3rd parameter, offset.

In example, you would have the entire text as the input, searching for a period after let's say the first 500 characters. So, assuming you don't have a huge run-on sentence, the text should be very close to your estimate of 500 characters. You'll display the text from position 0 to the position returned by strpos() using substr(). Then, the rest you can display on your other page, either from the position from strpos() or from the beginning again, whatever you want.

example:
Blah blah blah blah ....
...[500th character] This is a bunch more text. Blah blah blah...

Code:
$string = 'Blah blah blah blah .... this is the same text from above...';
$pos = strpos($string, '.', 500); //527 characters past the 500th character is the first period
echo substr($string, 0, $pos); //echo everything from the beginning to $pos, 527 characters
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
I already have the code to create a majority of the stuff necessary but i'm having trouble getting the text that I enter to format properly, does anyone have a theoretical way this can be done? I was thinking of doing like a character to line ratio but i cant get my mind to wrap around how it would work

Do you mean how to split up the amount of text, like garrettroyce is suggesting?

Exactly what do you mean by "format properly"?
 

garrensilverwing

New Member
Messages
148
Reaction score
0
Points
0
when i get the text it comes, basically, as one large page of text, i want to write some code that will break it up into several pages
 

lhyman

New Member
Messages
198
Reaction score
0
Points
0
May I suggest that you try re-writing your web page with a WYSIWYG editor....

Paid:

Dream Weaver
Web Expessions

Free:

HTML Kit
NVU
 

garrensilverwing

New Member
Messages
148
Reaction score
0
Points
0
May I suggest that you try re-writing your web page with a WYSIWYG editor....

Paid:

Dream Weaver
Web Expessions

Free:

HTML Kit
NVU

? how is that helpful? i already use expression web but it doesnt help much with php scripting...
 

garrensilverwing

New Member
Messages
148
Reaction score
0
Points
0
ah thanks for the article that is helpful ;) but i do want it to be broken up onto different pages too
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
I'm pretty sure the simple script I wrote is what you want. If it's not, I'd be happy to revise it :p
 

garrensilverwing

New Member
Messages
148
Reaction score
0
Points
0
well the thing is the size of the window for the page is already set and the lengths of the paragraphs and the number of characters per page varies quite a bit

here is a question: is there a way to store div overflow into a php variable?
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
What do you want, the text to fill perfectly like a book/magazine?
 

garrensilverwing

New Member
Messages
148
Reaction score
0
Points
0
What do you want, the text to fill perfectly like a book/magazine?

well due to the type of text it is there are some line breaks in weird places (like three characters and then a line break) so it won't fill perfectly like a book, i just want it to recognize when it fills up the area's rows with content and then moves the next section to the next page, and then when that one is filled moves the next section and so on until all the content is separated out

maybe this helps: i have 34 lines per page i need to fill either with content or line breaks
 
Last edited:
Top