Return to Snippet

Revision: 16843
at August 17, 2009 23:42 by traeregan


Initial Code
setlocale(LC_ALL, 'en_US.UTF8');
function toAscii($str, $replace=array(), $delimiter='-') {
	if( !empty($replace) ) {
		$str = str_replace((array)$replace, ' ', $str);
	}

	$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
	$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
	$clean = strtolower(trim($clean, '-'));
	$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);

	return $clean;
}

Initial URL
http://cubiq.org/the-perfect-php-clean-url-generator/12

Initial Description

                                

Initial Title
String to Clean URL Generator

Initial Tags
url

Initial Language
PHP