Home > Backend Development > PHP Tutorial > Incomplete solution to automatic paging_PHP tutorial

Incomplete solution to automatic paging_PHP tutorial

WBOY
Release: 2016-07-21 15:58:21
Original
939 people have browsed it

测试代码


  
  

$content=$_POST["content"];
//echo $content;
$ft=array("","

");
//echo count($ft);

$html = "abaaaaaaacssssssssssssssssssdefdddddddddddddddddd";
preg_match_all ("|()|U",$html,$out, PREG_PATTERN_ORDER);
 while (list($key,$value) = each($out[1])) {

 }


$keywords = preg_split ("/()/", $html);
//echo $html;
$pagesize=10;
$size=0;
$h="";
for ($i=0; $i< count($keywords); $i++) {
 if($size<$pagesize){
 $size+=strlen($keywords[$i]);
// echo "size=".$size;
 $h.=$keywords[$i];
 }
}

echo $h;
?>

思路是使用  将文章内容分解为多个块.形成数组
然后遍例,同时将文章内容块,一点点组合,直到它的长度大于 $pagesize

这是一个不错的方法,使用正则的 preg_split 进行文章内容的分割,是考虑到,以后不光使用 同时使用 

  或者更多的分割符号

但问题是,同时使用多个分割符后, 无法判断某一段是根据哪个分割符进行分割的. 无法对文章内容完整还原

项目比较紧,而且添加文章的编辑器是fckeditor,每个文章都有n多的.就暂时不考虑多个分割符了

 所以还不算是完整的解决方案. 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/317606.htmlTechArticle测试代码 formid="form1"name="form1"method="post"action="" textareaname="content"cols="60"rows="10"/textarea inputtype="submit"name="Submit"value="提交"/ /form ? $content=$_POS...
source:php.cn
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