Forum Moderators: coopster
function url_to_link($input) {
while(preg_match('/(?!<a target="_blank" href=")(?:http:\/\/)?(www(\.[\d\w\$\-_\.\+!\*\'\(\),%]+)+(\?[\d\w\$\-_\.\+!\*\'\(\),&=%]*)?)(?!(">)|(</a>))/is', $input, $out)) {
$repl = '<a target="_blank" href="http://' . $out[1] . '">' . $out[0] . '</a>';
$input = str_replace($out[0], $repl, $input)
}
return $input;
}
function url_to_link($input) {
while(preg_match('/(?<!<a\starget="_blank"\shref=")(?:http:\/\/)?(www(\.[\d\w\$\-_\.\+!\*\'\(\),%]+)+(\?[\d\w\$\-_\.\+!\*\'\(\),&=%]*)?)(?!(">)|(</a>))/is', $input, $out)) {
$repl = '<a target="_blank" href="http://' . $out[1] . '">' . $out[0] . '</a>';
$input = str_replace($out[0], $repl, $input)
}
return $input;
}
function url_to_link($input) {
if(preg_match_all('/http:\/\/(?:www\.)?([^\.\s]+)(\.[^\.\?\s]+)+(\?.*)?/is', $input, $out)) {
foreach($out[0] as $find) {
$repl = '<a target="_blank" href="' . $find . '">[' . $out[1] . ']</a>';
$input = str_replace($find, $repl, $input);
}
}
}
function url_to_link($input) {
if(preg_match_all('/http:\/\/(?:www\.)?(([^\.\s]+)(\.[^\.\?\s]+)+)(\?.*)?/is', $input, $out)) {
foreach($out as $find) {
$repl = '[<a target="_blank" href="' . $find[0] . '">' . $find[1] . '...</a>]';
$input = str_replace($find[0], $repl, $input);
}
}
return $input;
}
url_to_link($my_unformatted_string);