I have a text as description for example "Hello, this is my website for getting access - http://www.abcxyz.com/testcontroller/testfunction"
I need to show partial text as first 70 characters of description and followed by '...'.
So result for partial text should be 'Hello, this is my website for getting access - <a href='http://www.abcxyz.com/testcontroller/testfunction'>http://www.abcxyz.com/test...</a>'
. But the i need to convert the partial string to URL with full link.
I have used regular expression to convert string to url as -
function createUrlLink($text) {
$url = '@(http)?(s)?(://)?(([a-zA-Z])([-\w]+\.)+([^\s\.]+[^\s]*)+[^,.\s])@';
$return_text = preg_replace($url, '<a href="http$2://$4" target="_blank" title="$0">$0</a>', $text);
return $return_text;
}
This works fine for whole description. But i need to get this work for partial string url. Is there any solution ?