PHP processes several methods for parsing HTML strings. In the LieHuo. Net Tutorial, we often need to go to a substring in the html string. The following describes several methods for php to solve this problem: 1. strip_tags () function: can be filtered out.
Tutorial on helping customers (www.Bkjia.com)We often need to go to a substring in the html string. The following describes several php methods to solve this problem:
1. strip_tags () function: filters out HTML and PHP tags and returns a brand new string!
Usage:
String strip_tags (string to be processed [, string tag to be retained])
For example, the tag is written in this way. strip_tags ($ str, ""). to keep multiple tags, use spaces to separate them.
2. mixed processing with strpos and substr
When the string we want to intercept has a unique identifier, we can usually use this method. for example, to obtain a tag abc with a unique id, you only need to find and, the contents in the middle are all displayed.
3. PHP DOMDocument
The method provided by DOMDocument is to output plain text without any labels. if you only need text data, this method is the easiest way to pull
Digest (LieHuo.. Net) in the tutorial, we often need to go to a substring in the html string. The following describes several php methods to solve this problem: 1. strip_tags () function: filter out...