1

I have an index.html code like this

<div class="photoImg">
<img src="http://host.com/images/image-name.jpg" alt="image" />
</div>

and I use this code to findout the image url (http://host.com/images/image-name.jpg)

    <?php
    include('simple_html_dom.php');
$url = "index.html";
echo $url;
foreach($html->find('div.photoImg') as $photo){
$item['src'] = $photo->find('img', 0)->src;
$photo[] = $item;
}
print_r($photo);
?>

But It doesn't work. Can anyone help me fix my code !

Phuc Khung
  • 29
  • 1
  • 6

2 Answers2

1

Try this solution:

$photodivs = $html->find('div.photoimg');
foreach($photodivs as $photo)
$images[] = $photo->find('img',0)->src;
var_dump($images);
0

Did you try to pass the photoImg class directly to the image?

elasticman
  • 641
  • 8
  • 20