RE: [PHP] auto link?

From: Date: Mon, 16 Jul 2001 20:46:03 +0000
Subject: RE: [PHP] auto link?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58118@lists.php.net to get a copy of this message
Here's a function I use on a text field.. function activateUrls( $s ) { $o = ''; while ($s != '') { $url = ''; $temp = split('://', $s, 2); if (count($temp)>1) { # '://' found; now extract schema $s = $temp[1]; $temp2 = split('[^[:alpha:]]', strrev($temp[0]), 2); $schema = strrev($temp2[0]); # this gets schema $o .= substr($temp[0], 0, strlen($temp[0])-strlen($schema)); if ($schema != '') { # this ensures a non-null schema $temp3 = split("[[:space:],'\"<>:]", $s, 2); $url = $schema . '://' . $temp3[0]; $ns = substr($s, strlen($temp3[0]),1) . $temp3[1]; if ($temp3[0] != '') { $o .= "<a href=$url target=_new>$url</a>"; } else { $o .= $url; } $s = $ns; } else { $o .= '://'; } } else { $o .= $s; $s = ''; } } // while return $o; } Hope this helps, Chad -----Original Message----- From: zerosumzero@yahoo.com [mailto:zerosumzero@yahoo.com] Sent: Monday, July 16, 1979 4:01 PM To: php-general@lists.php.net Subject: [PHP] auto link? On Ray's advice I've given up on letting the users put html into my form. But I would like any http:// type addresses they include to be turned into hyper links: <a href=http://www.mysite.com>www.mysite.com</a> is there a script or function some place I can use to do this? Or must I try to write something of my own? Susan -- susan@futurebird.com http://futurebird.diaryland.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#58118) next »