Home > Backend Development > PHP Problem > How to use regular expression to remove p tag in php

How to use regular expression to remove p tag in php

藏色散人
Release: 2023-03-05 19:36:02
Original
4724 people have browsed it

php uses regular expressions to remove the p tag: [preg_replace("/|<\/p>/is","", $str)]. The preg_replace() function is used to perform a regular expression search and replacement.

*?>

How to use regular expression to remove p tag in php

The preg_replace() function is used to perform a regular expression search and replacement.

Recommended: "php Video Tutorial"

The code example is as follows:

$new = preg_replace("/<p.*?>|<\/p>/is","", $str);
var_dump($new);
Copy after login

The above is the detailed content of How to use regular expression to remove p tag in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template