#native_company# #native_desc#
#native_cta#

Url to Link (it works!)

By Lorenz
on December 28, 2002

Version: 1.0

Type: Function

Category: HTML

License: GNU General Public License

Description: This function trasforms a string (or a text) to an hyperlink.
Example:
my site is http://www.lolloland.com

will be trasformed to:
my site is <a href=”http://www.lolloland.com”; target=”TARGET”>www.lolloland.com</a>.

This function replaces a http, https or www in a text with a html A tag.

It works! Belive me!

<?php
//============================================================================== 
// 
// Function:     
// 
// Input:       STRING $str    - a text or line
//		STRING $target - define the link's target
// 
// Output:      STRING $str2 - a text or line with the links replaced with a 
//                             <A href tag 
// 
// Description: This function replaces a http, https or www in a text with a 
//              html A tag       
// 
// Original script      : http://www.zend.com/codex.php?id=904&single=1
// Original script name : OUCH
// Modified by          : lorenz at lolloland dot com (http://www.lolloland.com)
//============================================================================== 
function makeHref($str, $target="_blank")
{		
		// case insensitive regexp. 
		 	     // -- protocol tag or www 
		$str2 = preg_replace("!(((http(s?)://)|(www.))".    
		             // -- rest of the host, topdomain is 2-4 letters 
		             "([-a-z0-9.]{2,}.[a-z]{2,4}".                                      
		             // -- port (optional) 
		             "(:[0-9]+)?)".                
		             // -- path (optional) 
		             "((/([^s]*[^s.,"'])?)?)".  
		             // -- parameters (optional, but obligated to begin with a question mark) 
		             "((?([^s]*[^s.,"'])?)?))!i",     
		             // replace it with <a tag 
		             "<a href="http4://5689" target="$target">1</a>", 
		             $str); 
		return $str2; 
}
?>