[ create a new paste ] login | about

Link: http://codepad.org/6Dgk0yuC    [ raw code | output | fork ]

PHP, pasted on Jul 17:
1
2
3
4
5
6
7
8
9
<?php
$text = "here is a link to www.google.com";
$text2 = "here is a link to http://www.stackoverflow.com";
$content = preg_replace('!((http://|www\.)+[a-z0-9_./?=&-]+)!i', '<a href="$1">$1</a> ', $text." ");
echo $content;
echo "\n";
$content = preg_replace('!((http://|www\.)+[a-z0-9_./?=&-]+)!i', '<a href="$1">$1</a> ', $text2." ");
echo $content;
?>


Output:
1
2
here is a link to <a href="www.google.com">www.google.com</a>  
here is a link to <a href="http://www.stackoverflow.com">http://www.stackoverflow.com</a>  


Create a new paste based on this one


Comments: