0 Replies - 1286 Views - Last Post: 13 September 2011 - 09:16 AM

#1 E_Geek   User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 236
  • Joined: 20-February 11

plainTextToHtmlLinks

Posted 13 September 2011 - 09:16 AM

Description: Plug and play. Examples given with snippet. Will convert: protocol:url:domain url:domain and [email protected] plain text links to html links.
\1", $str); //http 
	$str = preg_replace("/([_.0-9a-z-][email protected]([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})/i", "\1", $str); // mail 
	
    return $str; 
    } 

// Mailto Example
$string = "[email protected]";
echo plainTextToHtmlLinks($string);


echo "

";

// No Protocol Example
$string = "www.example.com";
echo plainTextToHtmlLinks($string);

echo "

";

// FTP Protocol Example
$string = "ftp://www.example.com";
echo plainTextToHtmlLinks($string);

?>


Is This A Good Question/Topic? 0
  • +

Page 1 of 1