3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $message = "Lorem ipsum dolor sit amet, consectetur http://www.adipiscing.nl elit. Etiam sit amet http://www.odio.com leo. Mauris vitae sem sed diam ultricies egestas semper a risus. Mauris sem tortor, hendrerit eget aliquet ac, lacinia in tortor. http://www.Aenean.co.uk mauris nibh, luctus sit amet ipsum aliquet, vestibulum aliquam sem. Cras non felis sodales, pretium augue non, porttitor tortor."; $words = explode(" ", $message); $_words = array(); foreach($words as $word){ if(filter_var($word, FILTER_VALIDATE_URL) === false){ $_words[] = $word; } else{ $_words[] = "<a href=\"$word\">$word</a>"; } } echo implode(" ", $_words);
Output for 5.2.1 - 7.1.0
Lorem ipsum dolor sit amet, consectetur <a href="http://www.adipiscing.nl">http://www.adipiscing.nl</a> elit. Etiam sit amet <a href="http://www.odio.com">http://www.odio.com</a> leo. Mauris vitae sem sed diam ultricies egestas semper a risus. Mauris sem tortor, hendrerit eget aliquet ac, lacinia in tortor. <a href="http://www.Aenean.co.uk">http://www.Aenean.co.uk</a> mauris nibh, luctus sit amet ipsum aliquet, vestibulum aliquam sem. Cras non felis sodales, pretium augue non, porttitor tortor.
Output for 5.2.0
<a href="Lorem">Lorem</a> <a href="ipsum">ipsum</a> <a href="dolor">dolor</a> <a href="sit">sit</a> <a href="amet,">amet,</a> <a href="consectetur">consectetur</a> <a href="http://www.adipiscing.nl">http://www.adipiscing.nl</a> <a href="elit.">elit.</a> <a href="Etiam">Etiam</a> <a href="sit">sit</a> <a href="amet">amet</a> <a href="http://www.odio.com">http://www.odio.com</a> <a href="leo.">leo.</a> <a href="Mauris">Mauris</a> <a href="vitae">vitae</a> <a href="sem">sem</a> <a href="sed">sed</a> <a href="diam">diam</a> <a href="ultricies">ultricies</a> <a href="egestas">egestas</a> <a href="semper">semper</a> <a href="a">a</a> <a href="risus.">risus.</a> <a href="Mauris">Mauris</a> <a href="sem">sem</a> <a href="tortor,">tortor,</a> <a href="hendrerit">hendrerit</a> <a href="eget">eget</a> <a href="aliquet">aliquet</a> <a href="ac,">ac,</a> <a href="lacinia">lacinia</a> <a href="in">in</a> <a href="tortor.">tortor.</a> <a href="http://www.Aenean.co.uk">http://www.Aenean.co.uk</a> <a href="mauris">mauris</a> <a href="nibh,">nibh,</a> <a href="luctus">luctus</a> <a href="sit">sit</a> <a href="amet">amet</a> <a href="ipsum">ipsum</a> <a href="aliquet,">aliquet,</a> <a href="vestibulum">vestibulum</a> <a href="aliquam">aliquam</a> <a href="sem.">sem.</a> <a href="Cras">Cras</a> <a href="non">non</a> <a href="felis">felis</a> <a href="sodales,">sodales,</a> <a href="pretium">pretium</a> <a href="augue">augue</a> <a href="non,">non,</a> <a href="porttitor">porttitor</a> <a href="tortor.">tortor.</a>
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function filter_var() in /in/HWbgG on line 8
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: filter_var() in /in/HWbgG on line 8
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: filter_var() in /in/HWbgG on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: filter_var() in /in/HWbgG on line 8