PHP Simple_html_dom issue
Posted
by stef
on Stack Overflow
See other posts from Stack Overflow
or by stef
Published on 2010-05-29T22:54:10Z
Indexed on
2010/05/29
23:02 UTC
Read the original article
Hit count: 347
The snippet below loops through some web pages, grabs the html and then looks for table.results and gets the plaintext out of the tags contained in each . $results is ok.
Now I'm trying to get the href value of an tag that is found in the second of each . I'd like to include this in the $results array, but I'm not sure how to do this. The third foreach statement gets them but then I need to merge $links with $results. Ideally I'd also get the links in the second foreach statement.
Does anyone know how?
$i = 0;
foreach( $urls as $u )
{
$html = file_get_html($u);
foreach($html->find('.results tbody tr') as $element)
{
$result[$i] = $this->extract($element->plaintext);
$i++;
}
foreach($html->find('.results tbody tr a') as $element)
{
$links[$i] = $element->href;
$i++;
}
}
print_r($result);
print_r($links);
die;
© Stack Overflow or respective owner