ludo1960 Posted February 6, 2019 Share Posted February 6, 2019 Hi guys, I'm using http://simplehtmldom.sourceforge.net/manual.htm and my code is : $html = file_get_html('test/somefile.html'); if(!empty($html)){ foreach($html->find('ul') as $ul) { $testul[] = $ul->outertext; if (isset($testul[2])) { $links = $testul[2] ; } } $html2 = str_get_html($links) ; foreach($html2->find('a') as $a) { $links2 = $a->href ; } } echo '<pre>',print_r($links, 1),'</pre>'; The links array prints out a nice html page, and I would like to grab all the a tags for that page. I tried $html2 = str_get_html($links) ; as you see in my code above, but the $links2 page only prints out the last a tag. So I need to either convert the $html2 string to an array or find a way to extract the (a) tags from a string. Any ideas? Link to comment Share on other sites More sharing options...
ludo1960 Posted February 6, 2019 Author Share Posted February 6, 2019 And just after I posted I found the answer. grrrrrrrrrr!!!!!! if(!empty($html)){ foreach($html->find('ul') as $ul) { $testul[] = $ul->outertext; if (isset($testul[2])) { $links = $testul[2] ; } } $html2 = str_get_html($links) ; foreach($html2->find('a') as $a) { $links2[] = $a->href ; } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.