<?php
$str='<ul><li><a href=”http://web.zhaicool.net/” title=”PHP正则提取a标签链接” target=”_blank”>前端撸码笔记</a></li><li><a href=”http://web.zhaicool.net/” title=”PHP正则提取a标签链接” target=”_blank”>前端撸码笔记</a></li></ul>’;
$preg=’/<a .*?href=”(.*?)”.*?>/is’;
preg_match_all($preg,$str,$match);
$searchurl=””;
for($i=0;$i<count($match[1]);$i++)
{
$searchurl=$searchurl.$match[1][$i].”,”;
}
echo $searchurl;
?>
未经允许不得转载:前端撸码笔记 » PHP正则提取a标签链接