PHP processing parsing HTML strings in several ways _php tutorial

Source: Internet
Author: User
   home of the Help (www.Bkjia.com) tutorialOften we need to go to a string of strings in an HTML string, and here are a few ways that PHP handles such problems:

1.strip_tags () function: You can filter out HTML and PHP tags and return a completely new string!

Usage:

String Strip_tags (string to be processed [, the label that string wants to retain])

For example: tags, just write, Strip_tags ($str, ""), if you want to keep more than one label, the labels are separated by a space.

2. Mix with Strpos, substr

When we want to intercept the string, there is a unique identifier, usually can use this method, such as a unique ID with a label ABC, as long as the find and, the middle of the content is out.

3.PHP DOMDocument

DOMDocument provides a way to output plain text without any labels, and if you only need text data, use this method to pull the simplest

http://www.bkjia.com/PHPjc/364252.html www.bkjia.com true http://www.bkjia.com/PHPjc/364252.html techarticle Fire Net (liehuo.net) tutorial often we need to go to a string of strings in the HTML string, here are a few ways to handle the problem of PHP: 1.strip_tags () function: can filter out ...

  • 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.