Possible Duplicate:
Grabbing the href attribute of an A element
I need to parse all links of an HTML document that contain some word (it's always different).
Example:
<a href="/bla:bla">BLA</a>
<a href="/link:link">BLA</a>
<a href="/link:bla">BLA</a>
I only need the links with "href=/link: ...." what's the best way to go for it?
$html = "SOME HTLM ";
$dom = new DomDocument();
@$dom->loadHTML($html);
$urls = $dom->getElementsByTagName('a');
foreach ($urls as $url)
{
echo "<br> {$url->getAttribute('href')} , {$url->getAttribute('title')}";
echo "<hr><br>";
}
In this example all links are shown, I need specific links.
By using a condition.