I have two foreach loops. One gives image href="URL"s and the other gives image src="URL"s.
How do I combine these two loops together and display images?
My code which gives image HREFs:
foreach($doc->getElementsByTagName('a') as $a){
foreach($a->getElementsByTagName('img') as $img){
echo $a->getAttribute('href');
}
}
My code which gives image SRCs:
foreach($html->find('img') as $e)
echo $e->src . '<br>';
Try following.
Your code is echoing
a->hreffor every image. If that’s what you want to do, then try the following.