我在找一种方法将array
更改为preg_replace
。preg替换函数和http://?
// URLS
$pattern[1] = '/\[url\=(.*?)\](.*?)\[\/url\]/i';
$replace[1] = "<a href=\"http://$1\">$2</a>";
// IMAGES
$pattern[2] = '/\[img\=(.*?)\]/i';
$replace[2] = "<img src=\"http://$1\" alt=\"\" />";
因此,如果用户包括http://
它不会增加它,如果用户不添加http://
它会添加。
目前,它只有在用户无视http://
感谢
新年快乐工作!
现在就试试这个:)我只是用preg_replace'$ input = str_replace('http:// http://','http://' ,$ input);'但不是很漂亮 – cgweb87 2011-12-31 22:31:46