note 21088 deleted from function.preg-replace by sniper
| From: | sniper@php.net | Date: | Sun, 07 Sep 2003 22:07:38 +0000 |
| Subject: | note 21088 deleted from function.preg-replace by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-55711@lists.php.net to get a copy of this message | ||
Note Submitter: davidbyng@hotmail.com
----
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);
}
?>