We want to write the original article content page program, the principle is very simple, is in the editor when we insert page breaks in the editor, and then in the display we directly use explode pagination can be achieved, of course, there is more advanced is the paging to save the different records, and then generate a relatively complex.
The body is divided by a certain string, after the partition in accordance with the index number of the array, the current page number corresponding to the value of the array output can, as if to say enough faint, the following example:
| The code is as follows |
Copy Code |
|
$str = "ASD is Uncle Uncle ASD anti-virus hair [NextPage] born ah master asd ah master ASD a speed hair what place";
Receive the page number (1 if it doesn't exist)
$page = $_request[' page ')? $_request[' page ': 1;
Splitting content with a separator
$arr = Explode ("[NextPage]", $STR);
If the size of the split array is 1, the page is not paged
if (count ($arr) ==1) {
Echo $str;
}else{
Output the appropriate content by page number
echo $arr [$page-1];
Pagination page number
for ($i =1; $i <=count ($arr); $i + +) {
if ($page = = $i) {//Current page
echo "". $i. " ";
}else{
echo "". $i. " ";
}
}
}
?> |
http://www.bkjia.com/PHPjc/631517.html www.bkjia.com true http://www.bkjia.com/PHPjc/631517.html techarticle we want to write the native too article content paging program, the principle is very simple, is in the editor when we insert a page break in the editor, and then when the display we directly use explode pagination can ...