Parse a URL from a link

Discussion in 'PHP' started by Kennedy, Jul 12, 2007.

  1. #1
    Let's say I have a string:

    $link = "<a href=\"http://domainname.com/page.php\">This is my page.</a>";

    What I want to do is snag the url out of that string without anything else. Outputting:

    $url = "http://domainname.com/page.php";

    Does anyone know how this could be done?

    Thanks in advance.
     
    Kennedy, Jul 12, 2007 IP
  2. 4GU.RU

    4GU.RU Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    $link = "<a href=\"http://domainname.com/page.php\">This is my page.</a>";

    if (ereg('\"(.*)\"',$link,$out)){$url=$out[0];}

    dont verify true
     
    4GU.RU, Jul 12, 2007 IP