SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP and links (quession 2)

    I have in my database (MySQL) text which contains links.
    It's ok, if this link starts with http://mypage.com
    or www.maypage.com, then I use:

    PHP Code:
    $text ereg_replace("(http://[^[:space:]]+)"'<a href="\\1">\\1</a>'$text);
    $text ereg_replace("(www[^[:space:]]+)"'<a href="http://\\1">\\1</a>'$text); 
    But if link starts with http://www.mypage.com, then all is messed up.
    Can anyone give me the soluton?

    PS. what does it mean: [^[:space:]]+ and \\1

    Thanks!

  2. #2
    SitePoint Zealot Ace Nova's Avatar
    Join Date
    Aug 2000
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well are you talking (http://www.mypage.com) or http://www.mypage.com, cause i can clearly see you are using "( )" around the url also if you are using any capitals at the start it can mess things up

    ereg_replace is CaSe SeNsItIvE, use eregi_replace which isnt

    [^[:space:]]+ and \\1

    the space one means you are excluding spaces via pattern matching
    the \\1 means you are displaying the data from the first pattern matching you did in the ereg_replace
    Ace Nova
    Football Man
    InternetSprite.Com - Coming Soon!

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Ace Nova
    well are you talking (http://www.mypage.com) or http://www.mypage.com, cause i can clearly see you are using "( )" around the url
    Because I'm beginner, i don't know the difference...


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
  •