How to use the Lookup function PHP long article page function with the use of methods, will not split the paragraph, page to the bottom

Source: Internet
Author: User
Copy CodeThe code is as follows:


{
Global $expert _id;
$PageLength = 2000; Words per page
$CLength = strlen ($content);
$PageCount = Floor (($CLength/$PageLength) + 1; Count pages
$PageArray =array ();
$Seperator = Array ("\ n", "\ R", ". ","! ","? ",";",",","”","'"); Delimited symbols
echo "pages:". $PageCount. "
";
echo "Length:". $CLength. "


";
The Strpos () function returns the position of the first occurrence of a string in another string
if ($CLength < $PageLength)
{
Echo $content;
}else{
$PageArray [0]=0;
$Pos = 0;
$i = 0;
First page
for ($j =0; $j {
echo $Seperator [$j];
$Pos =strpos ($content, $Seperator [$j], $PageArray [$i]+1900);
while ($Pos > 0 && $Pos < ($i + 1) * $PageLength && $Pos > $i * $PageLength)
{
$PageArray [$i] = $Pos;
$Pos = Strpos ($Pos + $PageLength, $content, $Seperator [$j]);
}
if ($PageArray [$i]>0)
{
$j = $j + sizeof ($Seperator) + 1;
}
}
//---
for ($i =1; $i < $PageCount-1; $i + +) {
for ($j =0; $j {
echo $Seperator [$j];
$Pos =strpos ($content, $Seperator [$j], $PageArray [$i -1]+1900);
while ($Pos > 0 && $Pos < ($i + 1) * $PageLength && $Pos > $i * $PageLength)
{
$PageArray [$i] = $Pos;
$Pos = Strpos ($Pos + $PageLength, $content, $Seperator [$j]);
}
if ($PageArray [$i]>0)
{
$j = $j + sizeof ($Seperator) + 1;
}
}
}
--Last page
$PageArray [$PageCount -1]= $CLength;
$page = 2;
if ($page ==1)
{
$output =substr ($content, 0, $PageArray [$page -1]+2);
}
if ($page >1 && $page <= $PageCount)
{
$output =substr ($content, $PageArray [$page -2]+2, $PageArray [$page -1]-$PageArray [$page-2]);
$output = "(prev.)." ($page-1). " page) \ n ". $output;
}
echo str_replace ("\ n", "
", $output);
if ($page = = $PageCount)
Return $output =substr ($content, $PageArray [$page -2]+2, $PageArray [$page -1]-$PageArray [$page-2]);
if ($PageCount >1)
{
echo "


";
echo "". $page. " /". $PageCount." Page ";
if ($page >1)
echo "Prev";
Else
echo "Prev";
for ($i =1; $i <= $PageCount; $i + +)
{
echo "[". $i. "]";
}
if ($page < $PageCount)
echo "Next page";
Else
echo "Next page";
echo " ";
}
}
}?>


Use

Copy the Code code as follows:


$c
$current =$_request[' page_t '];
$result =ff_page ($content 1, $current);
echo $result;
?>


The above describes the use of the lookup function, PHP long article paging function with the use of the method, will not split the paragraph, page to the bottom, including the use of the lookup function of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    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.