$pattern = '`.*?((http|https)://[\w#$&+,\/:;=?@.-]+)[^\w#$&+,\/:;=?@.-]*?`i';
if (preg_match_all($pattern,$url_string,$matches)) {
print_r($matches[1]);
}
得到如下数组:

用 str_ireplace 批量替换字符串中的url:
$info['content'] = str_ireplace($arr,$url,$info['content']);
网友评论