note 21088 added to function.preg-replace

From: Date: Sun, 28 Apr 2002 17:33:02 +0000
Subject: note 21088 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-29952@lists.php.net to get a copy of this message
Here is a function I made for parsing Hyper links: <?php function parseHyper($string) { $search = array ("/([\w\.\/\&\=\?\-]+)@([\w\.\/\&\=\?\-]+)/", "/((ftp(7?):\/\/)|(ftp\.))([\w\.\/\&\=\?\-]+)/", "/((http(s?):\/\/)|(www\.))([\w\.\/\&\=\?\-]+)/"); $replace = array ("<a href='mailto:$1@$2'>$1@$2</a>", "<a href='ftp$3://$4$5' target='_blank'>$4$5</a>", "<a href='http$3://$4$5' target='_blank'>$4$5</a>"); return preg_replace ($search, $replace, $string); } ?> -- http://www.php.net/manual/en/function.preg-replace.php http://master.php.net/manage/user-notes.php?action=edit+21088 http://master.php.net/manage/user-notes.php?action=delete+21088 http://master.php.net/manage/user-notes.php?action=reject+21088

« previous php.notes (#29952) next »