Jump to content

Splitting content?


Hulio

Recommended Posts

Hi,

 

anybody knows, if there's a way to split the HTML -page content automtically to pages. Like let's say that I have a div sized 400 x 300 px including just some text and it doesn't fit there and I don't want it to make any scrolls. In other words I just want it to create another page if the content grows too much, like for example over 500 chars. Does this make any sense? Thanks!

Link to comment
https://forums.phpfreaks.com/topic/42223-splitting-content/
Share on other sites

You can use str_split() (PHP5+) if you want to split the text.

Then, according to the page number (defined by GET for an example), output the desired value from the array created by str_split():

 

<?php
//$str holds your string

$split = str_split($str, 500); //Split the string
$page = $_GET['page']; //The page we are in, add some validation here

echo $split[$page-1]; //Echo the desired part

?>

 

 

Orio.

Link to comment
https://forums.phpfreaks.com/topic/42223-splitting-content/#findComment-204814
Share on other sites

Well I think the example I gave pretty much shows it all. I don't know how your pages look like so I have no idea how you are going to fit it in. I just gave a basic example.

In my opinion, splitting the text into pages is not a great idea anyways. If you really want to split it, split it into different divs on the same page.

 

Orio.

Link to comment
https://forums.phpfreaks.com/topic/42223-splitting-content/#findComment-204825
Share on other sites

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.