SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    preg_match_all help

    ill try to explain this the best i can, right now i have some code that scans a document and returns all the a href links for example if the document contained < a href="link.php"> it would return link.php in the array.

    PHP Code:
    preg_match_all("'<\s*a\s.*?href\s*=\s*
                 ([\"\'])?
                 (?(1) (.*?)\\1 | ([^\s\>]+))
                 'isx"
    ,$document,$links); 
    If this is possible I want it to also return < a href="link.php" > THE INFO HERE </a>

    In a different array or something as well. Where it says THE INFO HERE whether it be an < img tag or text id like to put that in an array called $links2 if that is possible? Please help thank you in advance!

  2. #2
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think, re should be something like

    "~<a[^>]+href=([\"'])(.*?)\\1[^>]*>(.*?)</a>~si"

  3. #3
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it worked thank you so much!


Bookmarks

Posting Permissions

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