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