Jump to content

Archived

This topic is now archived and is closed to further replies.

zawadi

html links

Recommended Posts

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 text

HELP please :)

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

×

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.