Hulio Posted March 11, 2007 Share Posted March 11, 2007 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 More sharing options...
Orio Posted March 11, 2007 Share Posted March 11, 2007 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 More sharing options...
Hulio Posted March 11, 2007 Author Share Posted March 11, 2007 Thanks so much, I appreciate that a lot, but is there a chance to get an example or something for using this code, because my knowledge of PHP coding isn't in that level that could get this work...Sorry for bothering! Link to comment https://forums.phpfreaks.com/topic/42223-splitting-content/#findComment-204822 Share on other sites More sharing options...
Orio Posted March 11, 2007 Share Posted March 11, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.