Home > Backend Development > PHP Tutorial > How to use the lookup function PHP long article paging function with usage instructions, paragraphs will not be divided, pages will be turned at the bottom

How to use the lookup function PHP long article paging function with usage instructions, paragraphs will not be divided, pages will be turned at the bottom

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 08:41:00
Original
1428 people have browsed it

Copy code The code is as follows:


{
global $expert_id;
$PageLength = 2000; //Number of words per page
$CLength = strlen( $content);
$PageCount = floor(($CLength / $PageLength)) + 1; //Calculate the number of pages
$PageArray=array();
$Seperator = array("n","r",". ","! ","? ",";",",",""","'"); //delimiter
//echo "Page count:".$PageCount."
" ;
//echo "Length: ".$CLength."


";
//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=" (continued from page ".($page-1).")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 "Previous page ";
else
echo "Previous page";
for( $i=1;$i<=$PageCount;$i++)
{
echo "[".$i."]< ;/a> ";
}
if($page<$PageCount)
echo "
Next page< /a> ";
else
echo " next page";
echo "";
}
}
}?>


Use

to copy the code The code is as follows:


$c
$current=$_REQUEST['page_t'];
$result=ff_page($content1,$current);
echo $result;
?>


The above introduces how to use the lookup function. The PHP long article paging function comes with how to use it. It does not divide paragraphs, and the page is turned at the bottom. It includes how to use the lookup function. I hope it will be helpful to friends who are interested in PHP tutorials. .

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template