Return to Snippet

Revision: 52989
at November 9, 2011 04:52 by rwunsch


Initial Code
function Xauto_link($str, $attributes=array()) {
		$attrs = '';
		foreach ($attributes as $attribute => $value) {
			$attrs .= " {$attribute}=\"{$value}\"";
		}
		$str = ' ' . $str;
		$str = preg_replace(
			'`([^"=\'>])(((http|https|ftp)://|www.)[^\s<]+[^\s<\.)])`i',
			'$1<a href="$2"'.$attrs.'>$2</a>',
			$str
		);
		$str = substr($str, 1);
		$str = preg_replace('`href=\"www`','href="http://www',$str);
		// fügt http:// hinzu, wenn nicht vorhanden
		return $str;
	}

Initial URL

                                

Initial Description

                                

Initial Title
auto link urls in text / string

Initial Tags
url, link, text

Initial Language
PHP