Return to Snippet

Revision: 62179
at February 6, 2013 20:57 by federicoq


Initial Code
<?
function slug($phrase, $maxLength = 50) {
	$result = strtolower($phrase);
	$result = preg_replace("/[^a-z0-9\s-]/", "", $result);
	$result = trim(preg_replace("/[\s-]+/", " ", $result));
	$result = trim(substr($result, 0, $maxLength));
	$result = preg_replace("/\s/", "-", $result);
	return $result;
}
?>

Initial URL

                                

Initial Description
Slug.

Initial Title
function slug($string) — (gyural)

Initial Tags

                                

Initial Language
PHP