PHP Search Engine Optimized URL

Why is this important to Google ?

Well, the same reason we find "http://webarto.com/13/php-search-engine-optimized-url" more self-explaining then "http://webarto.com/node.php?id=13".

The following code replaces all characters that are not alphanumeric, this way we clean URL of any unnecessary characters in link. Blank spaces are replaced by dash.


function google($string){
	$string = strtolower($string);
	$A = array('č','ć','ž','đ','š');
	$B = array('c','c','z','dj','s');
	$string = str_replace($A,$B,$string);
	$string = preg_replace('/[^a-zA-Z0-9]/i','-',$string);
	$string = preg_replace("/(-){2,}/",'$1',$string);
	return $string;
}
©2009-2011 Webarto • web design & development • Tuzla // Sarajevo // Beograd