views:

24

answers:

1

Hey,

Does anyone know how i could use simple_html_dom's find function to find an html element specifying 2 attributes instead of 1?

Like right now I was using

$area2 = $html->find('td[width="450"]');

but say I want to also specify the height for the object, etc

How could I do it?

Thanks!

+1  A: 

I was hoping that $html->find('td[width=450][height=450]'); would work, but apparently not.

This works:

foreach ($html->find("td[width=100]") as $td) {
    $td_html = str_get_html($td->outertext);
    foreach ($td_html->find("td[height=100]") as $td) {
        print "$td\n";
    }
}

And so does this:

function height_filter($x) {
    return isset($x->height) && $x->height == "100";
}

foreach (array_filter($html->find("td[width=100]"),"height_filter") as $td) {
    print "$td\n";
}
Jamie Wong
Thanks your the best!
Belgin Fish