PHP7中文手册2018 带注释 最新chm版
本段代码是正则获取内容中的所有连接地址,这个在采集的时候经常用到
$con= file_get_contents($url);$pattern = '/<a(?:.*?)href="(((?:http(?:s?):\/\/)?([^\"\/]+))?(?:[^\"]*))"(?:[^>]*?)>([^<]*?)<\/a>/i';preg_match_all($pattern, $con, $links);$links = array_flip(array_flip($links[1]));转载请注明:谷谷点程序 » php正则取得网页上所有的链接(原创)