在我的网站中,我想用类似这样的其他链接替换链接
www.abc.com
或http://abc.com
将被替换为
http://www.XXXXXX.com/sonal?www.abc.com
或者
http://www.XXXXXX.com/sonal?http://abc.com
所以我正在使用这段代码,但这段代码给出了一些错误
Warning: preg_replace() [function.preg-replace]: Unknown modifier '/'
in /home/XXXXX/public_html/YYYYYYYYY/KKKKKK.php on line 495
$search_array = array(
"/\[url]www|http://.([^'\"]*)\[\/url]/iU",
"/\[url]([^'\"]*)\[\/url]/iU",
"/\[url=www|http://.([^'\"\s]*)](.*)\[\/url]/iU",
"/\[url=([^'\"\s]*)](.*)\[\/url]/iU"
);
$replace_array = array(
"<a href=\"http://XXXXXX.com/sonal?.\\1\" target=\"_blank\" rel=\"nofollow\">www. \\1</a>",
"<a href=\"\\1\" target=\"_blank\" rel=\"nofollow\">\\1</a>",
"<a href=\"http://XXXXXX.com/sonal?.\\1\" target=\"_blank\" rel=\"nofollow\">\\2</a>",
"<a href=\"\\1\" target=\"_blank\" rel=\"nofollow\">\\2</a>"
);
$msg = preg_replace($search_array, $replace_array, $msg);
return $msg;