Web Analytics Made Easy -
StatCounter parse string to link? - CodingForum

Announcement

Collapse
No announcement yet.

parse string to link?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • parse string to link?

    Hello,
    I'm trying to parse a string to a link,

    currently i'm using this, which works.

    PHP Code:
    preg_replace("/([^A-z0-9])(http|ftp|https|www)([\:\/\/])([^\\s]+)/"," <a href=\"$2$3$4\">$2$3$4</a>",$string); 
    but I've got one problem with this, that if it parses a string that already have "<a href='...'>link</a>" in it, then it doubles up the link, how can i get around this?

    thanks in advance for your time!
    -Ken

  • #2
    There's probably a better way, but the easiest way is to remove the <a href=""></a> stuff before you try to parse the other links.

    Comment

    Working...
    X