In this tutorial, We will learn how to find URL in string(text) and make clickable link in PHP 


Example:

<?php
  
$myString = "Some text is here with link: https://www.rathorji.com ";
  
$convertedString = convertURLs($myString);
print_r($convertedString);
  
  
function convertURLs($string)
{
    $url = '/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/';   
    return preg_replace($url, '<a href="$0" target="_blank" title="$0">$0</a>', $string);
}
  
?>


Thanks, I hope it will help you......