Are there any specific PHP functions or libraries that can help with automatically converting URLs in text to clickable links?

When working with text that contains URLs, it can be helpful to automatically convert those URLs into clickable links for better user experience. One way to achieve this is by using the PHP function `preg_replace` along with a regular expression pattern to identify URLs in the text and replace them with HTML anchor tags.

function auto_link_urls($text) {
    $pattern = '/(https?:\/\/\S+)/';
    $replacement = '<a href="$1" target="_blank">$1</a>';
    return preg_replace($pattern, $replacement, $text);
}

$text_with_links = auto_link_urls("Check out this cool website: http://www.example.com");
echo $text_with_links;