Her iki cevap içinde teşekkür ederim.

function shortenurl($url)
{
if ( strlen($url) > 45) {
return substr($url, 0, 30)."[...]".substr($url, -15);
} else {
return $url;
}
}

function getClickableLinks($text) {
$regex = '/(((http|https|ftp|ftps)\:\/\/)|(www\.))[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\:[0-9]+)?(\/\S*)?/';
return preg_replace_callback($regex, function ($matches) {
return "".shortenurl($matches[0])."";
}, $text);
}


kodları ile çözüm buldum.