Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<?php
$comment = "https://google.com and https://net-raft.com";
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
preg_match_all($reg_exUrl, $comment, $matches);
$usedPatterns = array();
foreach($matches[0] as $pattern){
if(!array_key_exists($pattern, $usedPatterns)){
$usedPatterns[$pattern]=true;
$comment = str_replace ($pattern, "<a href='{$pattern}' rel='nofollow'>{$pattern}</a> ", $comment);
}
}
echo $comment;
?>
</body>
</html>
The most helpful PHP solutions