Helpers/StringHelper.php
public static function createSlug($string)
	{
		// remove all accent characters
		$string = self::remove_accents($string);

		// lowercase
		$string = strtolower($string);

		// replace all characters except letters and numbers to dashes
		$slug = preg_replace('/[^A-Za-z0-9-]+/', '-', $string);

		// deep replace double dashes
		while(strpos('--', $slug))
		{
			$slug = str_replace('--', '-', $slug);
		}

		// trim dashes at start and end
		$slug = trim($slug, '-');

		return $slug;
	}
public static function createSlug($string)
	{
		// remove all accent characters
		$string = self::remove_accents($string);

		// lowercase
		$string = strtolower($string);

		// replace all characters except letters and numbers to dashes
		$slug = preg_replace('/[^A-Za-z0-9-]+/', '-', $string);

		// deep replace double dashes
		while(strpos('--', $slug))
		{
			$slug = str_replace('--', '-', $slug);
		}

		// trim dashes at start and end
		$slug = trim($slug, '-');

		return $slug;
	}
public static function createSlug ( $ string ) { // remove all accent characters $ string = self :: remove_accents ( $ string ) ; // lowercase $ string = strtolower ( $ string ) ; // replace all characters except letters and numbers to dashes $ slug = preg_replace ( '/[^A-Za-z0-9-]+/' , '-' , $ string ) ; // deep replace double dashes while ( strpos ( '--' , $ slug ) ) { $ slug = str_replace ( '--' , '-' , $ slug ) ; } // trim dashes at start and end $ slug = trim ( $ slug , '-' ) ; return $ slug ; }
Creates slug from any string

@param  string $string

@return string
Creates slug from any string