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

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

我使用 Whosebug 中的这段代码从字符串中创建标题 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);