ludo1960 Posted February 6, 2019 Share Posted February 6, 2019 (edited) 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? Edited February 6, 2019 by ludo1960 Quote Link to comment https://forums.phpfreaks.com/topic/308285-an-array-a-string-or-an-object/ 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 ; } } Quote Link to comment https://forums.phpfreaks.com/topic/308285-an-array-a-string-or-an-object/#findComment-1564264 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.