- preg_match: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$data = <<<EOF
<html>
<head>
<link href='http://wendyandgabe.blogspot.com/favicon.ico' rel='icon' type='image/x-icon'/>
<link href='http://wendyandgabe.blogspot.com/' rel='canonical'/>
<link rel="alternate" type="application/atom+xml" title="O' Happy Day! - Atom" href="http://wendyandgabe.blogspot.com/feeds/posts/default" />
<link rel="alternate" type="application/rss+xml" title="O' Happy Day! - RSS" href="http://wendyandgabe.blogspot.com/feeds/posts/default?alt=rss" />
<link rel="service.post" type="application/atom+xml" title="O' Happy Day! - Atom" href="http://www.blogger.com/feeds/5390468261501503598/posts/default" />
</head>
<body>
</body>
</html>
EOF;
preg_match_all('/<link[^>]+>/i',$data, $urls);
foreach($urls[0] as $url) {
if(preg_match('/application\/rss\+xml/i', $url)) {
preg_match('/href=["\']?([^"\'>]+)["\']?/i',$url, $match);
echo $match[1]."\n";
}
}