一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

PHP 長文章分頁函數 帶使用方法,不會分割段落,翻頁在底部

復制代碼 代碼如下:
<?php function ff_page($content,$page)
{
global $expert_id;
$PageLength = 2000; //每頁字數
$CLength = strlen($content);
$PageCount = floor(($CLength / $PageLength)) + 1; //計算頁數
$PageArray=array();
$Seperator = array("/n","/r","。","!","?",";",",","”","'"); //分隔符號

//echo "頁數:".$PageCount."<br>";
//echo "長度:".$CLength."<br><br><br>";
//strpos() 函數返回字符串在另一個字符串中第一次出現的位置
if($CLength<$PageLength)
{
echo $content;

}else{

$PageArray[0]=0;
$Pos = 0;
$i=0;
//第一頁
for($j=0;$j<sizeof($Seperator);$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<sizeof($Seperator);$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;
}
}
}


//--最后一頁
$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=" (上接第".($page-1)."頁)/n".$output;
}

echo str_replace("/n","<br>   ",$output);
//if($page==$PageCount)
//return $output=substr($content,$PageArray[$page-2]+2,$PageArray[$page-1]-$PageArray[$page-2]);

if($PageCount>1)
{
echo "<br><br><br><center>";
echo "<font color='ff0000'>".$page."</font>/".$PageCount." 頁  ";
if($page>1)
echo "<a href=$php_SELF?expert_id=$expert_id&page_t=".($page-1)."></a> ";
else
echo " ";

for($i=1;$i<=$PageCount;$i++)
{

echo "<a href=$php_SELF?expert_id=$expert_id&page_t=".$i.">[".$i."]</a> ";
}

if($page<$PageCount)
echo " <a href=$php_SELF?expert_id=$expert_id&page_t=".($page+1)."></a> ";
else
echo " ";

echo "</center>";
}
}

}?>

使用
復制代碼 代碼如下:
<?php
$content1=''測試文字,盡量長一些,www.jb51.NET";
$current=$_REQUEST['page_t'];
$result=ff_page($content1,$current);
echo $result;
?>

php技術PHP 長文章分頁函數 帶使用方法,不會分割段落,翻頁在底部,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: xh98hx国产免费 | 黄站视频| 91免费看国产 | 久久精品国产精品青草 | 在线色资源 | 狠狠色噜噜狠狠狠狠奇米777 | 亚洲国产精品91 | 丁香婷婷综合网 | 99福利在线 | 日本中文字幕一区二区有码在线 | 久久亚洲精品无码观看不卡 | 午夜视频免费在线观看 | 天天舔天天干 | 丁香六月婷婷综合 | 久久久噜噜噜久久中文字幕色伊伊 | 国产91一区二区在线播放不卡 | 国产性精品| 亚洲a人| 日本欧美韩国专区 | 欧色视频 | 亚洲 欧美 国产另类首页 | 91高清在线视频 | 美女免费精品高清毛片在线视 | 精品日韩欧美一区二区三区 | 午夜精品在线 | 日韩免费视频一区二区 | 婷婷久久综合九色综合98 | www欧美com| 亚洲伦理中文字幕一区 | 正在播放一区 | 日日噜噜夜夜躁躁狠狠 | 小说区图片区视频区 | 国产中日韩一区二区三区 | 美美女高清毛片视频免费观看 | 色婷婷影院 | 亚洲欧美日韩精品香蕉 | 91麻豆国产香蕉久久精品 | 99精品99 | 国产区图片区小说区亚洲区 | 亚洲图片欧美文学小说激情 | 婷婷丁香激情 |