Archive for April, 2013

25/04/2013

Identify a (web) link in a string with PHP

If you want to process some text and output the same text with HTML links automatically created for you, then look no further:

$newstring = preg_replace('!(http|ftp|scp)(s)?:\/\/[a-zA-Z0-9.?&_/]+!', "<a href=\"\\" target='_blank'>\</a>",$sting);

Advertisements
Tags: