php make text id attribute safe

Solutions on MaxInterview for php make text id attribute safe by the best coders in the world

showing results for - "php make text id attribute safe"
Maite
01 Sep 2019
1	function seoUrl($string) {
2		//Lower case everything
3		$string = strtolower($string);
4		//Make alphanumeric (removes all other characters)
5		$string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
6		//Clean up multiple dashes or whitespaces
7		$string = preg_replace("/[\s-]+/", " ", $string);
8		//Convert whitespaces and underscore to dash
9		$string = preg_replace("/[\s_]/", "-", $string);
10		return $string;
11	}