preg_replace() [function.preg-replace]: Unknown modifier '/' in /home/

回眸只為那壹抹淺笑 提交于 2019-12-02 11:24:38

There is few ways to solve that

Escaping "/"

$search_array = array(
  "/\[url]www|http:\/\/.([^'\"]*)\[\/url]/iU",
  "/\[url]([^'\"]*)\[\/url]/iU",
  "/\[url=www|http:\/\/.([^'\"\s]*)](.*)\[\/url]/iU",
  "/\[url=([^'\"\s]*)](.*)\[\/url]/iU"
);

Or using different regexp seperator like "#"

$search_array = array(
  "#\[url]www|http://.([^'\"]*)\[\/url]#iU",
  "#\[url]([^'\"]*)\[\/url]#iU",
  "#\[url=www|http://.([^'\"\s]*)](.*)\[\/url]#iU",
  "#\[url=([^'\"\s]*)](.*)\[\/url]#iU"
);
"/\[url]www|http://.([^'\"]*)\[\/url]/iU",
 ^               ^^                  ^

You either need to escape the two // in the middle to \/\/, or, better, use different delimiters for the regex:

"~\[url]www|http://.([^'\"]*)\[/url]~iU",
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!