Stackoverflow のこのコードを使用して、文字列からタイトル スラッグを作成しました
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