【发布时间】:2014-11-19 05:55:24
【问题描述】:
我需要使用php代码提取存储在<a>标签中的链接值。
我用下面的代码
$url = '<a title="Question" href="http://stackoverflow.com/questions/ask">t</a>';
preg_match("/href=\"(.*?)\"/i", $url, $matches);
print_r($matches);
通过上面的代码,我可以得到单个 href 的值。但它不适用于字符串中的多个href(即$url = '<a title="Question" href="http://stackoverflow.com/questions/ask">t</a><a href="x.php">x</a>';)。我怎样才能做到这一点?
【问题讨论】:
标签: php