PHP regular match replace image address

PHP中文网
Release: 2023-02-28 22:50:02
Original
2251 people have browsed it

PHP正则匹配替换图片地址:

网上能找到很多匹配图片src的正则表达式和替换的实例,都是然并卵,不能马上解决问题。

只是要找到src里的那一段给替换掉就行了。

给一段内容:

$content = '';
Copy after login

正则匹配替换:

preg_replace("/()/is","\${1}asdf\${3}",$content);
Copy after login

$content只要是一个PHP regular match replace image address标签里的全部内容就可以,将src里的内容单独圈起来,前后的内容都整个的包括起来,${1}和${3}就是src的前后内容,将src替换成想要的就行。

以上就介绍了PHP正则匹配替换图片地址,包括了方面的内容,更多相关内容请关注PHP中文网(www.php.cn)!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!