Incomplete automatic paging Solution

Source: Internet
Author: User

Test code

<Form id = "form1" name = "form1" method = "post" action = "">
<Textarea name = "content" cols = "60" rows = "10"> </textarea>
<Input type = "submit" name = "Submit" value = "submit"/>
</Form>
<?
$ Content = $ _ POST ["content"];
// Echo $ content;
$ Ft = array ("<br/>", "</p> ");
// Echo count ($ ft );

$ Html = "abaaaaaaa <br/> cssssssssssssssssssd <br/> efdddddddddddddddddd ";
Preg_match_all ("| (<br \/>) | U", $ html, $ out, PREG_PATTERN_ORDER );
While (list ($ key, $ value) = each ($ out [1]) {

}


$ Keywords = preg_split ("/(<br \/>)/", $ 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;
?>

The idea is to use <br/> to separate the content of the article into multiple blocks to form an array.
Next, repeat the example and combine the content blocks until the length is greater than $ pagesize.

This is a good method. The regular preg_split is used to split the content of the article, considering that not only <br/> but also </p> or more separator will be used in the future.

However, the problem is that after multiple delimiters are used at the same time, you cannot determine which delimiter a segment is based on. You cannot completely restore the content of the article.

The project is tight, and the editor for adding an article is fckeditor. Each article has more than n </br>. multiple separators are not considered for the moment.

So it is not a complete solution.

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.