创建标题辅助信息域时出错 注意:iconv():在输入字符串中检测到非法字符


Error while Creating title Slug Notice: iconv(): Detected an illegal character in input string in

我使用了 Stackoverflow 中的这段代码从字符串中创建标题 slug。

function slugify($text)
{
 // replace non letter or digits by -
 $text = preg_replace('~[^'pL'd]+~u', '-', $text);
 // transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
// remove unwanted characters
$text = preg_replace('~[^-'w]+~', '', $text);
// trim
 $text = trim($text, '-');
// remove duplicate -
$text = preg_replace('~-+~', '-', $text);
// lowercase
$text = strtolower($text);
if (empty($text))
{
  return 'n-a';
}
 return $text;
 } 

它对于大多数字符串都工作正常。 但是对于一些字符串,例如"Азур и Азмар/Azur et Asmar",得到这个。 我现在应该改变什么?

Notice: iconv(): Detected an illegal character in input string in 

尝试更改

$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);

$text = iconv('utf-8', 'us-ascii//IGNORE', $text);