PHP article content pagination Instance Program _php Tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.