So i want to loop trough specific TD
's in a LARGE html page. I'm using simplehtmldom in order to achieve that. The problem is that i cant make it work without putting every step in a foreach.
Here is my php
include('../inc/simple_html_dom.php');
$html = file_get_html("http://www.bjork-family.com/f43-london-stories");
// I just put the dom of pagebody into TEST
$test = $html->find('#page-body');
foreach($test->find('img') as $element)
{
echo "<img src='" . $element->src . "'/>" . '<br>';
}
i get this error
Fatal error: Call to a member function find() on array in /mywebsite.php on line 39
line 39 is this one
foreach($test->find('img') as $element)
I tried a lot of different things, if i keep it really really simple like that :
// Create DOM from URL or file
$html = file_get_html('http://www.bjork-family.com/f43-london-stories');
foreach($html->find('img') as $element)
echo $element->src . '<br>';
then it works !
So it seems to be working when i go like that
foreach($html->find('div') as $element)
{
if($element->id == 'page-body')
{
echo $element->id;
echo "EXIST <br>";
}
// echo "<img src='" . $element->src . "'/>" . '<br>';
}
But i don't want to search into my html only using foreach, is there another way where i can get to my position and then do i loop (i have to loop trough tr in a table )
Now
$test
is an arrayNow
$test
is an elementThis will work now. Also you can simplify with: