Return to Snippet

Revision: 27526
at June 13, 2010 14:02 by metoikos


Initial Code
function replace_plain_text_link($plain_text) {
$url_html = preg_replace(
'/(?<!S)((http(s?):\/\/)|(www.))+([\w.1-9\&=#?\-~%;\/]+)/',
'<a href="http$3://$4$5">http$3://$4$5</a>', $plain_text);
return ($url_html);
}
echo replace_plain_text_link("hi this is dummy text before
http://www.smjdesign.com hi this is dummy text after")

Initial URL

                                

Initial Description

                                

Initial Title
php text to link

Initial Tags
regex, php, link, text

Initial Language
PHP