Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts

    Extracting an element from an array ?

    Hi,
    I am using this expression to pick up the url from my document:

    PHP Code:
    preg_match("/href=\"(.*?)\"/",$text,$matchesPREG_OFFSET_CAPTURE); 
    When I print the array with:
    print_r($matches);

    I get this:
    Array ( [0] => Array ( [0] => href="http://sbinfocanada.about.com/od/salesselling/a/increasesales.htm" [1] => 55 ) [1] => Array ( [0] => http://sbinfocanada.about.com/od/sal...reasesales.htm [1] => 61 ) )
    How do I pick up this bit "http://sbinfocanada.about.com/od/salesselling/a/increasesales.htm " ?

    i.e. $saved_url = $matches[ ??

    I tried various combinations like:
    PHP Code:
    echo "<br><br><br>Match: $matches['1[0]']"
    but without success

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,307
    Thanks
    4
    Thanked 205 Times in 202 Posts
    PHP Code:
    $saved_url $matches[1][0]; 
    Dave .... HostMonster for all of your hosting needs

  • #3
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Thanks - thats great


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •