- Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.27
- Parse error: syntax error, unexpected '{' in /in/02Fpr on line 10
Process exited with code 255.
<?php
function formatUrlsInText($text){
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
preg_match_all($reg_exUrl, $text, $matches);
$usedPatterns = array();
foreach($matches[0] as $pattern){
if(!array_key_exists($pattern, $usedPatterns)){
$usedPatterns[$pattern]=true;
$text = str_replace($pattern, "<a href=".{$pattern}." rel="nofollow">{$pattern}</a> ", $text);
}
}
return $text;
}
$str = 'Hi bro! Look at my new website: www.example.com. I leard to build websites from http://another.example.net and from example.net.';
$newStr = formatUrlsInText($str);
echo $newStr;