Thanks Feherke, I've turned your function into this
function LinkURLs($text) {
$text = str_replace("/","/",$text);
return preg_replace_callback('@(http)?(s)?(://)?(([-\w]+\.)+([^\s]+)+[^,.\s])@', function($match) {
if (strlen($match[4]) > 30) {
$text = substr($match[4], 0...