Utils/StringUtils.php
/**
     * This function removes all special characters from a string. They are replaced by $replacement,
     * multiple $replacement are replaced by just one, $replacement is also trimmed from the beginning
     * and the end of the string.
     *
     * @param string $string the original text
     * @param string $replacement the replacement, - by default
     * @param bool $lower return string in lower case, true by default
     * @return string $string the modified string
     */
This function removes all special characters from a string. They are replaced by $replacement,
multiple $replacement are replaced by just one, $replacement is also trimmed from the beginning
and the end of the string.

@param string $string the original text
@param string $replacement the replacement, - by default
@param bool $lower return string in lower case, true by default
@return string $string the modified string
This function removes all special characters from a string . They are replaced by $replacement multiple $replacement are replaced by just one $replacement is also trimmed from the beginning and the end of the string . @param string $string the original text @param string $replacement the replacement - by default @param bool $lower return string in lower case true by default @return string $string the modified string
public static function removeSpecChars($string, $replacement = '-', $lower = true)
    {
        $specChars = array(
            'Á' => 'A',
            'Â' => 'A',
            'Ã' => 'A',
            'Ä' => 'Ae',
            'Å' => 'A',
            'Æ' => 'A',
            'Ç' => 'C',
            'È' => 'E',
            'É' => 'E',
            'Ê' => 'E',
            'Ë' => 'E',
            'Ì' => 'I',
            'Í' => 'I',
            'Î' => 'I',
            'Ï' => 'I',
            'Ð' => 'E',
            'Ñ' => 'N',
            'Ò' => 'O',
            'Ó' => 'O',
            'Ô' => 'O',
            'Õ' => 'O',
            'Ö' => 'Oe',
            'Ø' => 'O',
            'Ù' => 'U',
            'Ú' => 'U',
            'Û' => 'U',
            'Ü' => 'Ue',
            'Ý' => 'Y',
            'Þ' => 'T',
            'ß' => 'ss',
            'à' => 'a',
            'á' => 'a',
            'â' => 'a',
            'ã' => 'a',
            'ä' => 'ae',
            'å' => 'a',
            'æ' => 'ae',
            'ç' => 'c',
            'è' => 'e',
            'é' => 'e',
            'ê' => 'e',
            'ë' => 'e',
            'ì' => 'i',
            'í' => 'i',
            'î' => 'i',
            'ï' => 'i',
            'ð' => 'e',
            'ñ' => 'n',
            'ò' => 'o',
            'ó' => 'o',
            'ô' => 'o',
            'õ' => 'o',
            'ö' => 'oe',
            'ø' => 'o',
            'ù' => 'u',
            'ú' => 'u',
            'û' => 'u',
            'ü' => 'ue',
            'ý' => 'y',
            'þ' => 't',
            'ÿ' => 'y',
            '_' => $replacement
        );
        $string    = strtr($string, $specChars);
        $string    = trim(preg_replace('~\W+~u', $replacement, $string), $replacement);
        return $lower ? strtolower($string) : $string;
    }
public static function removeSpecChars ( $ string , $ replacement = '-' , $ lower = true ) { $ specChars = array ( 'Á'  >  A', 'Â'  >  A', 'Ã'  >  A', 'Ä'  >  Ae', 'Å'  >  A', 'Æ'  >  A', 'Ç'  >  C', 'È'  >  E', 'É'  >  E', 'Ê'  >  E', 'Ë'  >  E', 'Ì'  >  I', 'Í'  >  I', 'Î'  >  I', 'Ï'  >  I', 'Ð'  >  E', 'Ñ'  >  N', 'Ò'  >  O', 'Ó'  >  O', 'Ô'  >  O', 'Õ'  >  O', 'Ö'  >  Oe', 'Ø'  >  O', 'Ù'  >  U', 'Ú'  >  U', 'Û'  >  U', 'Ü'  >  Ue', 'Ý'  >  Y', 'Þ'  >  T', 'ß'  >  ss', 'à'  >  a', 'á'  >  a', 'â'  >  a', 'ã'  >  a', 'ä'  >  ae', 'å'  >  a', 'æ'  >  ae', 'ç'  >  c', 'è'  >  e', 'é'  >  e', 'ê'  >  e', 'ë'  >  e', 'ì'  >  i', 'í'  >  i', 'î'  >  i', 'ï'  >  i', 'ð'  >  e', 'ñ'  >  n', 'ò'  >  o', 'ó'  >  o', 'ô'  >  o', 'õ'  >  o', 'ö'  >  oe', 'ø'  >  o', 'ù'  >  u', 'ú'  >  u', 'û'  >  u', 'ü'  >  ue', 'ý'  >  y', 'þ'  >  t', 'ÿ'  >  y', '_' => $ replacement ) ; $ string = strtr ( $ string , $ specChars ) ; $ string = trim ( preg_replace ( '~\W+~u' , $ replacement , $ string ) , $ replacement ) ; return $ lower ? strtolower ( $ string ) : $ string ; }
This function removes all special characters from a string.
This function removes all special characters from a string .