Jump to content
Sign in to follow this  
ludo1960

php simple dom find all children

Recommended Posts

Hi guys,

I am usingĀ this dom parser, and its pretty easy to find all links on a page then following the links to sub pages, but how do I know when to stop, i.e.when the page has no more children? I came across this script for dealing with child pages, but needless to say it outputs nothing:

$links = $html->find('div.layout');

    foreach ($links as $link) {
        foreach ($link->children() as $children) {
            if ($children->tag == 'a') {
                $output [] = $children->plaintext; //or whatever you want
            }
        }
    } 

How do I test for a link that has no more children?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.