I found a routine to create a html link when a link is found in a text
Without RegEx:
' . $token . '' . PHP_EOL;
}
}
}
// sample data
$data = array(
'test one http://www.mysite.com/',
'http://www.mysite.com/page1.html test two http://www.mysite.com/page2.html',
'http://www.mysite.com/?go=page test three',
'https://www.mysite.com:8080/?go=page&test=four',
'http://www.mysite.com/?redir=http%3A%2F%2Fwww.mysite.com%2Ftest%2Ffive',
'ftp://test:six@ftp.mysite.com:21/pub/',
'gopher://mysite.com/test/seven'
);
// test our sample data
foreach ($data as $text) {
makelink($text);
}
?>
Output:
http://www.mysite.com/
http://www.mysite.com/page1.html
http://www.mysite.com/page2.html
http://www.mysite.com/?go=page
https://www.mysite.com:8080/?go=page&test=four
http://www.mysite.com/?redir=http%3A%2F%2Fwww.mysite.com%2Ftest%2Ffive
ftp://test:six@ftp.mysite.com:21/pub/
gopher://mysite.com/test/seven