3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function replace($url){ $url = str_replace("\\r","\r",$url); $url = str_replace("\\n","\n<BR>",$url); $url = str_replace("\\n\\r","\n\r",$url); $in=array( '`((?:https?|ftp)://\S+[[:alnum:]]/?)`si', '`((?<!//)(www\.\S+[[:alnum:]]/?))`si', '`((?:https?|ftp)://\S+[[:alnum:]]\.(png|jpeg|jpg|gif)\b`si', //'`((?<!//)(www\.\S+[[:alnum:]]\.(png|jpeg|jpg|gif)\b))`si' ); // это для ссылок и фото $out=array( '<a style="color:navy;" href="$1" rel="nofollow">$1</a>', '<a style="color:navy;" href="http://$1" rel=\'nofollow\'>$1</a>', '<img src="$1" rel="nofollow">', //'<img src="http://$1" rel=\'nofollow\'>' ); return preg_replace($in, $out, $url); } echo replace('dfd dfdf http://site.ru/ ddd fff');
Output for 5.2.5 - 7.1.0
Warning: preg_replace(): Compilation failed: missing ) at offset 54 in /in/aKR6T on line 20
Output for 4.3.11 - 5.2.4
Warning: preg_replace(): Compilation failed: missing ) at offset 54 in /in/aKR6T on line 20 dfd dfdf <a style="color:navy;" href="http://site.ru/" rel="nofollow">http://site.ru/</a> ddd fff
Output for 4.3.0 - 4.3.10
Warning: Compilation failed: missing ) at offset 54 in /in/aKR6T on line 20 dfd dfdf <a style="color:navy;" href="http://site.ru/" rel="nofollow">http://site.ru/</a> ddd fff