3v4l.org

run code in 300+ PHP versions simultaneously
<?php function modifyText($text) { $url = '~https?://[a-zA-Z0-9.-]+\.[a-zA-Z]{2,3}(?:\/\S*(?<!\.))?~'; $string= preg_replace($url, '<a href="$0" target="_blank">$0</a>', $text); return $string; } echo modifyText("Example text... https://example.com/site. More text here... https://example.com/site");

preferences:
35.85 ms | 404 KiB | 5 Q