Clean URL improves

This commit is contained in:
dignajar 2015-08-07 14:59:21 -03:00
parent e76d9ff651
commit 903b3a5293
1 changed files with 16 additions and 0 deletions

View File

@ -52,6 +52,7 @@ class Text {
return $text; return $text;
} }
/*
public static function cleanUrl($string, $separator='-') public static function cleanUrl($string, $separator='-')
{ {
// Delete characters // Delete characters
@ -72,6 +73,21 @@ class Text {
return $string; return $string;
} }
*/
public static function cleanUrl($string, $separator='-')
{
if(function_exists('iconv')) {
$string = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
}
$string = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $string);
$string = trim($string, '-');
$string = self::lowercase($string);
$string = preg_replace("/[\/_|+ -]+/", $separator, $string);
return $string;
}
// Replace all occurrences of the search string with the replacement string. // Replace all occurrences of the search string with the replacement string.
public static function replace($search, $replace, $string) public static function replace($search, $replace, $string)