开发者

php, checking correctnes of text splitting

开发者 https://www.devze.com 2022-12-28 03:07 出处:网络
I need to split html document on two parts. First part, should contain N(30) words, and next one should contain everything else.

I need to split html document on two parts. First part, should contain N(30) words, and next one should contain everything else. And the main problem, is to prevent splitting tags (description and body of tags)开发者_JAVA百科.

  1. <a **<=>** href="text" > text </a>

  2. <a href="text" > **<=>** text </a>

  3. <a href="text" > text </ **<=>** a>

Give me please suggestions (or if you have already written such function, please share your code), how to realize it! Thanks.


Use DOM Parser, documentation you can find at http://php.net/manual/en/book.dom.php

You can parse your html in a tree with this class, and get your result by tree manipulation and saving your data.

0

精彩评论

暂无评论...
验证码 换一张
取 消