Uploader

An all around general purpose file uploader for CakePHP. Packaged as a stand alone plugin with file validation, file scanning and support for a wide range of basic mime types.

Slugify

Transform text into a URL slug. Replaces whitespaces with dashes and removes non alpha-numeric characters.

Function: slugify()
Category: Javascript
Views: 3,669
Permalink - Tinylink

/**
 * Transform text into a URL slug: spaces turned into dashes, remove non alnum
 * @param string text
 */
function slugify(text) {
	text = text.replace(/[^-a-zA-Z0-9,&\s]+/ig, '');
	text = text.replace(/-/gi, "_");
	text = text.replace(/\s/gi, "-");
	return text;
}

Return to Snippets