View Single Post
rufopr rufopr is offline 2002-08-08 #7 Old  
though i'd post this up because it did fix my url problems

$link =
preg_replace("/\b((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.]+)\b/i",
"<a href=\"http$3://$4$5$6\"
target=\"_blank\">$2$4$5$6</a>", $link);

i tested it and and worked like a charm, it pick up anything beginning with http: or www. and prints it out as a link..

i can't understand it cause it's a little to advaced for me... can anybody explain it to me? what are $2, $3, $4, $5, $6? what are '\b' 's?' 'i'?

i also haven't fixed the double quotes problem yet if anybody wants to contribute on that
Reply With Quote