php iconv Translatit用于去除重音:不使用magento manufacture徽标';s

php iconv Translatit用于去除重音:不使用magento manufacture徽标';s,php,magento,Php,Magento,我想更换一些字符,这是不工作的,我是例外的magento制造标志,这是显示在产品属性。 这是我在manufacture_center.phtml上的代码,我正在编写清除不需要的特殊字符的函数,该函数可以很好地用于删除特殊字符,但不能用于像“a,e”这样的字符,我需要将其替换为“a,e”: 我已经解决了这个问题 function manu_title_clean($text,$strict,$str = false) { $text = preg_replace('~[^\\pL\d.]+~u',

我想更换一些字符,这是不工作的,我是例外的magento制造标志,这是显示在产品属性。 这是我在manufacture_center.phtml上的代码,我正在编写清除不需要的特殊字符的函数,该函数可以很好地用于删除特殊字符,但不能用于像“a,e”这样的字符,我需要将其替换为“a,e”:


我已经解决了这个问题

function manu_title_clean($text,$strict,$str = false) {
$text = preg_replace('~[^\\pL\d.]+~u', '-', $text);
// trim
$text = trim($text, '-');
setlocale(LC_CTYPE, 'en_GB.utf8');
$unwanted_array = array(    'Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
                        'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
                        'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
                        'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
                        'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
   $str = strtr( $text, $unwanted_array );
   $text = strtolower($str);
   $text = preg_replace('~[^-\w.]+~', '', $text);
   if (empty($text)) {
   return 'empty_$';
    }
   if ($strict) {
    $text = str_replace(".", "_", $text);
    }
    return $text;

    }

我已经解决了这个问题

function manu_title_clean($text,$strict,$str = false) {
$text = preg_replace('~[^\\pL\d.]+~u', '-', $text);
// trim
$text = trim($text, '-');
setlocale(LC_CTYPE, 'en_GB.utf8');
$unwanted_array = array(    'Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
                        'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
                        'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
                        'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
                        'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
   $str = strtr( $text, $unwanted_array );
   $text = strtolower($str);
   $text = preg_replace('~[^-\w.]+~', '', $text);
   if (empty($text)) {
   return 'empty_$';
    }
   if ($strict) {
    $text = str_replace(".", "_", $text);
    }
    return $text;

    }

结果似乎取决于iconv的版本(libc6 2.24中的版本已停止工作)。

结果似乎取决于iconv的版本(libc6 2.24中的版本已停止工作)。

您能否提供iconv()的//TRANSLIT无法正常工作的示例文本?我在你的问题中使用了原始的例子(“–,é”),它的音译很好。请参见,您能否提供iconv()的//Translatit无法正常工作的示例文本?我在你的问题中使用了原始的例子(“–,é”),它的音译很好。看见