Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php make text id attribute safe

	function seoUrl($string) {
		//Lower case everything
		$string = strtolower($string);
		//Make alphanumeric (removes all other characters)
		$string = preg_replace("/[^a-z0-9_s-]/", "", $string);
		//Clean up multiple dashes or whitespaces
		$string = preg_replace("/[s-]+/", " ", $string);
		//Convert whitespaces and underscore to dash
		$string = preg_replace("/[s_]/", "-", $string);
		return $string;
	}
 
PREVIOUS NEXT
Tagged: #php #text #id #attribute #safe
ADD COMMENT
Topic
Name
7+2 =