Extract url from string

Discussion in 'PHP' started by amorph, Jun 10, 2007.

  1. #1
    Does anyone know a good way of extracting the second url out of this link?

    http://localhost/somesite/index.php/login/index/http://www.asdasd.as.com/asd?=asdas

    It should get out :

    http://www.asdasd.as.com/asd?=asdas

    I tried some regex but I suck so bad.

    Thanks.
     
    amorph, Jun 10, 2007 IP
  2. Vbot

    Vbot Peon

    Messages:
    107
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can try:
    $link = "http://localhost/somesite/index.php/login/index/http://www.asdasd.as.com/asd?=asdas";
    list($junk1, $junk2, $newlink) = explode("//", $link);
    echo "http://$newlink";
    
    PHP:
     
    Vbot, Jun 11, 2007 IP
  3. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $link = "http://localhost/somesite/index.php/login/index/http://www.asdasd.as.com/asd?=asdas";
    echo strrchr($link, 'http:');
    PHP:
     
    decepti0n, Jun 11, 2007 IP