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."; $message = preg_replace('@(https?://([-\w.]+[-\w])+(:\d+)?(/([\w-.~:/?#\[\]\@!$&\'()*+,;=%]*)?)?)@', '<a href="$1" target="_blank">$1</a>', $message); echo $message;
Output for 4.3.0 - 7.1.0
Lorem ipsum dolor sit amet, consectetur <a href="http://www.adipiscing.nl" target="_blank">http://www.adipiscing.nl</a> elit. Etiam sit amet <a href="http://www.odio.com" target="_blank">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" target="_blank">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.