note 14770 added to function.eregi-replace.php
| From: | webdev at jakecarlson dot com | Date: | Tue, 14 Aug 2001 08:11:11 +0000 |
| Subject: | note 14770 added to function.eregi-replace.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16687@lists.php.net to get a copy of this message | ||
Hello everyone:
I'd just like to contribute two code snippets. This took me a LONG time to come up with
because I am not an experienced programmer.
Anyway, I am making a chat program and I wanted the user input to automatically replace any URLs and
email addresses with links on the chat screen, so I used the following:
$message =
eregi_replace("([a-zA-Z]+)://([a-zA-Z0-9\._-]+)(\.[a-zA-Z]+)","<strong><a
href=\"\\1://\\2\\3\"
target=\"_blank\">\\1://\\2\\3</a></strong>", $message);
$message = eregi_replace("([a-zA-Z0-9_-]+)@([a-zA-Z0-9\._-]+)(\.[a-zA-Z]+)",
"<strong><a href=\"mailto:\\1@\\2\\3\">\\1@\\2\\3</a></strong>",
$message);
Jake
http://www.php.net/manual/en/function.eregi-replace.php