public static function getUrlTitle($str, $separator = '-', $lowercase = true) {
		if($separator === 'dash') {
			$separator = '-';
		}
		elseif($separator === 'underscore') {
			$separator = '_';
		}

		$qSeparator = preg_quote($separator, '#');
		$trans = array(
				'&.+?:;'         => '',
				'[^a-z0-9 _-]'      => '',
				'\s+'           => $separator,
				'('.$qSeparator.')+'   => $separator
			);

		$str = strip_tags($str);
		foreach ($trans as $key => $val) {
			$str = preg_replace('#'.$key.'#i', $val, $str);
		}

		if ($lowercase === true) {
			$str = strtolower($str);
		}

		return trim(trim($str, $separator));
	}
public static function getUrlTitle($str, $separator = '-', $lowercase = true) {
		if($separator === 'dash') {
			$separator = '-';
		}
		elseif($separator === 'underscore') {
			$separator = '_';
		}

		$qSeparator = preg_quote($separator, '#');
		$trans = array(
				'&.+?:;'         => '',
				'[^a-z0-9 _-]'      => '',
				'\s+'           => $separator,
				'('.$qSeparator.')+'   => $separator
			);

		$str = strip_tags($str);
		foreach ($trans as $key => $val) {
			$str = preg_replace('#'.$key.'#i', $val, $str);
		}

		if ($lowercase === true) {
			$str = strtolower($str);
		}

		return trim(trim($str, $separator));
	}
public static function getUrlTitle ( $ str , $ separator = '-' , $ lowercase = true ) { if ( $ separator === 'dash' ) { $ separator = '-' ; } elseif ( $ separator === 'underscore' ) { $ separator = '_' ; } $ qSeparator = preg_quote ( $ separator , '#' ) ; $ trans = array ( '&.+?:;' => '' , '[^a-z0-9 _-]' => '' , '\s+' => $ separator , '(' . $ qSeparator . ')+' => $ separator ) ; $ str = strip_tags ( $ str ) ; foreach ( $ trans as $ key => $ val ) { $ str = preg_replace ( '#' . $ key . '#i' , $ val , $ str ) ; } if ( $ lowercase === true ) { $ str = strtolower ( $ str ) ; } return trim ( trim ( $ str , $ separator ) ) ; }
Create URL Title

Takes a "title" string as input and creates a
human-friendly URL string with a "separator" string
as the word separator.

@todo    Remove old 'dash' and 'underscore' usage in 3.1+.
@param   string  $str        Input string
@param   string  $separator  Word separator
(usually '-' or '_')
@param   bool    $lowercase  Wether to transform the output string to lowercase
@return  string
Create URL Title