Home  >  Article  >  Web Front-end  >  How to remove html tags

How to remove html tags

coldplay.xixi
coldplay.xixiOriginal
2021-04-26 11:38:445952browse

The way to remove html tags is to use the [strip_tags()] function to easily remove HTML and PHP tags from strings. The syntax is [trip_tags ( string $str [, string $allowable_tags ] )].

How to remove html tags

The operating environment of this tutorial: windows7 system, html5 version, DELL G3 computer.

How to remove html tags:

foreach ($list['company_list'] as $key => $value) {
$list['company_list'][$key]['summary'] =strip_tags($list['company_list'][$key]['summary']);//去除html标签
$list['company_list'][$key]['summary'] = str_replace(' ',' ', $list['company_list'][$key]['summary']);

Word explanation:

strip_tags()The function can easily remove HTML and PHP tags from strings.

Usage:

trip_tags ( string $str [, string $allowable_tags ] );

The first parameter is required, that is To remove source data from HTML and PHP tags, the second parameter is optional and indicates tags that do not need to be filtered.

str_replace()Function uses a string to replace other characters in a string

Syntax

str_replace(find,replace,string,count)

How to remove html tags

Related learning recommendations: html video tutorial

The above is the detailed content of How to remove html tags. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn