Home > Backend Development > PHP Problem > How to replace string with regular string in php

How to replace string with regular string in php

藏色散人
Release: 2023-03-07 06:30:02
Original
2376 people have browsed it

php正则字符串替换字符串的方法:首先创建一个PHP示例文件;然后通过“preg_replace($pattern, "", $string);”正则方法实现字符串替换字符串即可。$1$2>

How to replace string with regular string in php

推荐:《PHP视频教程

php用正则表达式替换部分字符串

例如:

<a style="color:#ccc; font-size=14px;" href="http://baidu.com">百度</a>
Copy after login

将字符串中style="color:#ccc; font-size=14px;"替换掉

/';
echo preg_replace($pattern, "", $string);
Copy after login

The above is the detailed content of How to replace string with regular string in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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