Ueditor How to extract <p> tag strings? or use PHP to extract the string

Source: Internet
Author: User
How to get from

The contents of the tag to extract a fixed number of characters as a post of the introduction? I see Baidu Bar is a post in front of a certain number of characters extracted as a post introduction to display. Let's say the following is an example of content

some content...

...
...

...

...

Due to a

The length of the content in the label is not fixed, and it may start with a picture label, or insert code

Label, and so on, suppose you want to

Extract 50 characters from the tag and don't know if it's OK. If it is not good to deal with, can use PHP efficient processing?

Reply content:

How to get from

The contents of the tag to extract a fixed number of characters as a post of the introduction? I see Baidu Bar is a post in front of a certain number of characters extracted as a post introduction to display. Let's say the following is an example of content

some content...

...
...

...

...

Due to a

The length of the content in the

tag is not fixed and may start with the picture tag, or insert the code

 tag and so on, suppose you want to extract 50 characters from the   

tag and don't know if it's OK. If it is not good to deal with, can use PHP efficient processing?

Hello, I feel can use regular to match, and then use Preg to extract the content, if this idea is not possible, you can use JS traversal to do. I hope you will be more specific, I can write a bit. If not, please correct me.

Regular + string intercept

]+> (. *?)


Simple regular bar.

Assuming that the

Tag has been found, You can use SUBSTR + strip_tags to do

How to find

Tags, you can use regular or phpquery

  • Related Article

    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.