pickachu Posted November 12, 2008 Share Posted November 12, 2008 how do i paginate an article into multiple pages? i tried to use substring but the problem is words are broken in some instances. i wanted it to end on an specific end paragraph tag.. Quote Link to comment https://forums.phpfreaks.com/topic/132419-paginate-an-article-into-multiple-pages/ Share on other sites More sharing options...
Adam Posted November 12, 2008 Share Posted November 12, 2008 I believe on some websites they use a special tag like: === BREAK === or something .. in which case you could explode the text by "=== BREAK ===" then have say "?page=2" in the URL and return the text at that index of the array. So something like: // assuming $article contains the text $page = (!$_GET['page']) 0 : (int) $_GET['page'] - 1; $article_pages = explode("=== BREAK ===", $article); echo $article_pages[$page]; .. not tested but it's just a quick idea. Adam Quote Link to comment https://forums.phpfreaks.com/topic/132419-paginate-an-article-into-multiple-pages/#findComment-688458 Share on other sites More sharing options...
pickachu Posted November 13, 2008 Author Share Posted November 13, 2008 are there any other methods than adding breaks? Quote Link to comment https://forums.phpfreaks.com/topic/132419-paginate-an-article-into-multiple-pages/#findComment-689001 Share on other sites More sharing options...
.josh Posted November 13, 2008 Share Posted November 13, 2008 No not really...you did say you want it to break at specific spots... If you were wanting it to break every 100 words or something, or every x paragraph tag, etc..then sure. The key is that you have to establish a pattern. If there's no pattern, then you have to use something as a marker, like a [pagebreak] tag. Quote Link to comment https://forums.phpfreaks.com/topic/132419-paginate-an-article-into-multiple-pages/#findComment-689013 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.