I'm having a problem trying to find an element with the exact name.
<?
//...
@$DOM = new DOMDocument;
@$DOM->loadHTML($html);
@$finder = new DomXPath($DOM);
foreach($finder->query("//a[contains(@title, '".$info[$i]."')]") as $link){
echo $l[$i] = $link->getAttribute('href').'<br>';
}
//...
?>
Your response is several links (caught from getAtrribute()
), no problem.
Where is the problem?
I would like to ONLY get what
title
is equal to$info[$i]
.
Exemplifying (note the title
!):
<a href='1.html' title="biscoito"></a>
<a href='2.html' title="biscoito bolacha"></a>
<a href='3.html' title="bolacha"></a>
If $info[$i]
had the value of " biscoito
", it would be returned:
1.html //oriundo do biscoito
2.html //oriundo do biscoito bolacha
Desired result:
1.html
Solution I need:
There is some function (which I do not know) that only filters the name equally, but not only contains it. Because I need only where title
is equal to cookie , but not the cookie cookie .