Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Content Management and PHP - can this be done?


toadhall - 5:25 pm on Apr 1, 2003 (gmt 0)


Trisha,

> a simple way for them to make links (without) showing them the html...

This script was written by someone here at WebmasterWorld. Didn't keep the thread url or note the author (was it you Andreas?) and can't find it in a Site Search.

It forms hyper links and mailto links of any full url or email address in the input text.

It's not the pop-up solution on your wish list, but a nice bit of work none the less.

<?
$text = "The url to this site is http://www.yubbadubbadoo.ca, if you'd like to visit.<br>Or mail them at info@yubbadubbadoo.ca";
// scan for hyper links...
$scan1 = ereg_replace("[A-Za-z]+://[^ <>\n]*[A-Za-z0-9/]", '<a href="\\0">\\0</a>', $text);
// scan for email addresses...
$scan2 = [1]ereg_replace('[A-Za-z0-9]([A-Za-z0-9._]*[A-Za-z0-9]¦())@[A-Za-z0-9]([A-Za-z0-9.\-]*[A-Za-z0-9]¦())\.[A-Za-z]+', [/1]'<a href="mailto:\\0">\\0</a>', $scan1);
echo ("$scan2");
?>

T

[edited by: jatar_k at 6:47 pm (utc) on April 1, 2003]


Thread source:: http://www.webmasterworld.com/php/610.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com