zawadi Posted July 4, 2006 Share Posted July 4, 2006 ok, I have an html file and I need to get the links in it out. But I dont know PHP well to do it, all I want is the HREF"" bit and the link textHELP please :) Link to comment https://forums.phpfreaks.com/topic/13640-html-links/ Share on other sites More sharing options...
Wildbug Posted July 4, 2006 Share Posted July 4, 2006 [code]preg_match_all('/<a href="(.*?)">(.*?)<\/a>/si',$html_text,$matches);preg_match_all('/<a.*?href="(.*?)".*?>(.*?)<\/a>/si',$html_text,$matches);[/code]That should put the link(s) in the [b]$matches[/b] array. The second one takes into consideration links with other "stuff" in them. See [url=http://www.php.net/manual/en/function.preg-match-all.php]the manual page[/url] for this function for more information. Link to comment https://forums.phpfreaks.com/topic/13640-html-links/#findComment-52899 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.