ludo1960 Posted February 26, 2019 Author Share Posted February 26, 2019 Yeah, got lots to learn. Wouldn't want it any other way! At least I try, that's got to count for something? Quote Link to comment https://forums.phpfreaks.com/topic/308369-array-hierarchy-and-filter/page/2/#findComment-1564857 Share on other sites More sharing options...
maxxd Posted February 26, 2019 Share Posted February 26, 2019 I haven't done any php DOM manipulation or parsing in quite some time and as far as I can recall I've not used the Simple HTML Dom Parser library (usually just use DOMDocument), but from the docs it looks this could be what you're looking for: foreach($html->find('li') as $li){ print("<p>{$li->first_child()->innertext}</p>"); } The first_child() of each list item element should be the anchor tag, and innertext should return the contents of that anchor tag. Unless I'm not reading something correctly - it's been a long day, so it's very possible that I am... 1 Quote Link to comment https://forums.phpfreaks.com/topic/308369-array-hierarchy-and-filter/page/2/#findComment-1564867 Share on other sites More sharing options...
ludo1960 Posted February 26, 2019 Author Share Posted February 26, 2019 Thanks again, changed a bit of your code and it works great for ( $i = 0 ; $i < count($li) ; $i++ ) { echo $li[$i]->children[0]->attr['href'] . '<br>' ; //echo $li[$i]->children[0]->children[0]->_[4] . '<br>' ; This was my effort lol! echo $li[$i]->first_child()->innertext } So now I have all I need to construct my associative array ! Great answer! thanks again Maxxd Quote Link to comment https://forums.phpfreaks.com/topic/308369-array-hierarchy-and-filter/page/2/#findComment-1564868 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.