SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Preg_Replace and URLS (HELP!)

    I have tried a lot of different things to solve my problem, but I just cant seem to do it. Can anybody help?

    I am trying to convert every 'href' found in a page to a bigger version.

    Example:
    <a href="http://www.google.com">google</a>
    to..
    <a href="http://www.mywebsite.com/index.php?href=http://www.google.com">MY google link</a>

    But the problem is, some people dont have full links.

    Example:
    <a href="/folder/index.php">link</a>

    So when I run it through, it changes to:
    <a href="http://www.mywebsite.com/index.php?href=/folder/index.php">MY link</a>
    Which obviously doesnt work since I am trying to link to a different domain.

    Can anybody help me do what I want?

    NOTE: To get the domain address, I can use the variable $src.

  2. #2
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be able to split an urls with parse_url and fill in missing parts (e.g. domain).


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
  •