(.*?)<\/a>/is ",]."/> (.*?)<\/a>/is ",].">

Home>Article>Backend Development> How to delete a tag in php using regular method

How to delete a tag in php using regular method

coldplay.xixi
coldplay.xixi Original
2020-10-08 15:56:50 3249browse

php正则方法删除a标签的方法:使用函数【preg_replace】保留,代码为【$str = htmlspecialchars_decode($str);$str = preg_replace("/]*>(.*?)92a8f4da390e1708e8ab2a88401e00d4/is",】。

How to delete a tag in php using regular method

php正则方法删除a标签的方法:

目的:

使用正则表达式删除下列内容中的a标签,同时保留a标签内容

欢迎来到php中文网m.sbmmt.com

修改后:

欢迎来到php中文网m.sbmmt.com

解决方法:

$str = " 欢迎来到php中文网m.sbmmt.com "; $str = htmlspecialchars_decode($str); $str = preg_replace("/]*>(.*?)<\/a>/is", "$1", $str); echo $str; 运行结果为: 1

想了解更多编程学习,敬请关注php培训栏目!

The above is the detailed content of How to delete a tag in php using regular method. 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