What function is being used for the automatic creation of hyperlinks in PHP?
To automatically create hyperlinks in PHP, you can use the `preg_replace` function along with a regular expression to search for URLs in a string and replace them with clickable hyperlinks. This can be useful when you have a block of text that contains URLs and you want to convert them into clickable links for better user experience.
<?php
function auto_link_urls($text) {
$pattern = '/(http[s]?:\/\/[^\s]+)/';
$replacement = '<a href="$1" target="_blank">$1</a>';
return preg_replace($pattern, $replacement, $text);
}
$text = "Check out my website at https://example.com";
echo auto_link_urls($text);
?>