Jump to content


html links

  • Please log in to reply
1 reply to this topic

#1 zawadi

  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationChippenham UK

Posted 04 July 2006 - 02:16 PM

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 :)
That's the beauty of asymmetric warfare. You don't need a lot of money, or an army of people. You can do it from the comfort of your living room, with a beer in your hand.

#2 Wildbug

  • Members
  • PipPipPip
  • Advanced Member
  • 1,149 posts

Posted 04 July 2006 - 02:38 PM

preg_match_all('/<a href="(.*?)">(.*?)<\/a>/si',$html_text,$matches);

That should put the link(s) in the $matches array.  The second one takes into consideration links with other "stuff" in them.  See the manual page for this function for more information.
Twice a day my clock works PERFECTLY!  I can't figure out what's wrong with it.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users