3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = <<<STR Hello @username you need to check this http://github.com and @username you need to https://stackoverflow.com/questions/ask or https://stackoverflow.com STR; $pattern = "~(?<!\S)(?:(@[^\s@]+)(?!\S)[^h]*(?:h(?!ttp)[^h]*)*+)?\K((?:https?|ftp|file)://\S+)~"; $result = preg_replace_callback($pattern, function($m){ return sprintf('<a href="%s">%s</a>', $m[2],$m[1] ?? $m[2]); }, $string); echo $result;

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
169 ms | 2154 KiB | 12 Q