Use the phpstrip_tags () function to keep multiple HTML tag instances

Source: Internet
Author: User
Tags string tags
The phpstrip_tags () function removes the HTML, XML, and PHP tags from the string and returns the string after the tag is removed. However, when we need to retain multiple HTML tags, how can I use the phpstrip_tags () function? This article introduces how to use the phpstrip_tags () function to retain multiple HTML tags. let's take a look. The php strip_tags () function removes HTML, XML, and PHP tags from strings and returns the strings after the tags are removed. However, when we need to retain multiple HTML tags, how can I use the php strip_tags () function? This article introduces how to use Php strip_tags () function to retain multiple HTML tagsLet's take a look.

Use the php strip_tags () function to retain multiple HTML tags. This mainly involves the second parameter of strip_tags. you can use the second parameter to set the tags that do not need to be deleted.

Usage

If there is such a string, the code is as follows:

$ Str ="

I'm fromPHP Chinese network

";

No HTML tags are retained. the code is as follows:

 I'm fromPHP Chinese network

"; Echo strip_tags ($ str) ;?>

Code running output:I'm from PHP.

To keep only one tag, you only need to write the string to the second parameter of strip_tags. the code is as follows:

 I'm fromPHP Chinese network

"; Echo strip_tags ($ str," ");?>

Code running output:I'm from PHP.

To retain

And... Multiple tags, separated by spaces, must be written to the second parameter of strip_tags:

 I'm fromPHP Chinese network

"; Echo strip_tags ($ str ,"

");?>

Code running output:

I'm fromPHP Chinese network

[Recommended related articles]

Detailed description of the strip_tags () function example for removing string tags from php

Notes for using the php strip_tags () function

The above describes how to use the php strip_tags () function to keep detailed details of multiple HTML tag instances. For more information, see other related articles in the first PHP community!

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.