HTML
<div class="imgw">
<ul>
<li>
<a href="http://somesites/index.html">
<img src="http://somesites.com/picture.jpg"/>
</a>
</li>
</ul>
</div>
PHP
$dom = new DOMDocument();
$dom->loadHTML($html);
$div = $dom->getElementByClass('imgw');
$links = $div->getElementsByTagName('a');
foreach ($links as $link) {
$li = $link->getAttribute('href');
echo ($li."<br>");
}
I have been looking at this (PHP DOMDocument
) but I still don't understand how to make it work.