Home > Backend Development > PHP Tutorial > preg_replace匹配尖括号的问题

preg_replace匹配尖括号的问题

WBOY
Release: 2016-06-23 13:55:57
Original
1321 people have browsed it

 $wenzis="我是<图片1>";$wenzi="黑色"; $tihuanzhi   = "<图片1>"; //要替换的值   $wenzis = preg_replace($tihuanzi, $wenzi, $wenzis,1);
Copy after login

替换结果是 "我是<黑色>",替换结果没把尖括号去掉,请教怎么把尖括号也替换掉


回复讨论(解决方案)

$wenzis = "我是<图片1>";$wenzi = "黑色";$tihuanzhi   = "/<图片1>/"; //要替换的值$wenzis = preg_replace($tihuanzhi, $wenzi, $wenzis,1);echo $wenzis;
Copy after login
我是黑色

搞定了,谢谢

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