title: Problem to get content from html string variable in php
body: <p>I have this code:</p>
  
  <pre><code>     $doc = new \DOMDocument();
    $doc-&gt;loadHTML($content);
  
  
      $links = [];
    $container = $doc-&gt;getElementById("content");
    $arr = $container-&gt;getElementsByTagName("a");
    foreach($arr as $item) {
      $href =  $item-&gt;getAttribute("href");
      $title =  $item-&gt;getAttribute("title");
      $links[] = [
        'href' =&gt; $href,
        'title' =&gt; $title
      ];
    }
    for($i = 0, $l = count($links); $i &lt; $l; ++$i) {
    echo $links[$i]['title'].' '.$links[$i]['href'].'&lt;br /&gt;';
  }
  </code></pre>
  
  <p>The html structure is like that:</p>
  
  <pre><code>&lt;div class="post-content right-col"&gt;
                      &lt;a title="" href="https://www.swisscars.pl/samochody/516321/"&gt;
                          &lt;img src="https://swisscars.pl/uploads2/180843_0.jpg" alt="" class="thumb alignleft" height="75" width="75"/&gt;
                      &lt;/a&gt;
                      &lt;h2 style="line-height:150%;"&gt;
                          &lt;a href="https://www.swisscars.pl/samochody/516321/" rel="bookmark"  title="Renault Kangoo II (96&amp;#8217;011 km)"&gt;
                              Renault Kangoo II (96&amp;#8217;011 km)                     &lt;/a&gt;
                      &lt;/h2&gt;
                  Do końca aukcji: &lt;span id="countdown100"&gt;2018-10-23 14:00:00 GMT+02:00&lt;/span&gt;&lt;p&gt;DATA ZAKONCZENIA AUKCJI: 2018-10-23 14:00&lt;/p&gt;
  
                  &lt;/div&gt;
  
              &lt;/div&gt;
  </code></pre>
  
  <p>I want to get only values from a tag witch attribute rel="bookmark". Please help me with this. I try to use hasAttribute function but is not working. Please describe me what I can get only content from a tag with rel="bookmark" attribute. PHP have hasAttribute() function or something like this function?</p>
  
  <p>Thanks for help</p>