title: Parse All Links That Contain A Specific Word In "href" Tag
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3820666/grabbing-the-href-attribute-of-an-a-element">Grabbing the href attribute of an A element</a>  </p>
  </blockquote>
  
  
  
  <p>I need to parse all links of an HTML document that contain some word (it's always different).</p>
  
  <p>Example:</p>
  
  <pre><code>&lt;a href="/bla:bla"&gt;BLA&lt;/a&gt;
  &lt;a href="/link:link"&gt;BLA&lt;/a&gt;
  &lt;a href="/link:bla"&gt;BLA&lt;/a&gt;
  </code></pre>
  
  <p>I only need the links with "href=/link: ...." what's the best way to go for it?</p>
  
  <pre><code>$html = "SOME HTLM ";
  $dom = new DomDocument();
  @$dom-&gt;loadHTML($html);
  $urls = $dom-&gt;getElementsByTagName('a');
  foreach ($urls as $url)
  {
      echo "&lt;br&gt; {$url-&gt;getAttribute('href')} , {$url-&gt;getAttribute('title')}";
      echo "&lt;hr&gt;&lt;br&gt;";
  }
  </code></pre>
  
  <p>In this example all links are shown, I need specific links.</p>