b4r7 blocco note 2.0

30apr/090

slug_me

a better (?) version of toAscii function by Matteo Spinelli

function slug_me($str, $replace=array(), $delimiter='-', $charset='ISO-8859-1') {
	$str = iconv($charset, 'UTF-8', $str);
	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;
}
Commenti (0) Trackback (0)

Ancora nessun commento.


Lascia un commento


Ancora nessun trackback.