title过滤函数

Published
2022-12-16
浏览次数 :  19

/*-----------------------------------------------------------------------------------*/
# Sanitizes a title, replacing whitespace and a few other characters with dashes.
/*-----------------------------------------------------------------------------------*/
function tie_sanitize_title( $title ){
	$title = strip_tags($title);
	$title = preg_replace('/&.+?;/', '', $title);
	$title = str_replace('.', '-', $title);
	$title = strtolower($title);
	$title = preg_replace('/[^%a-z0-9 :-]/', '', $title);
	$title = preg_replace('/\s+/', '-', $title);
	$title = preg_replace('|-+|', '-', $title);
	$title = trim($title, '-');

	return $title;
}

  • 标签1
  • 标签1
  • 标签1
Top