【发布时间】:2014-11-21 04:28:42
【问题描述】:
我尝试从字符串中生成 slug,但德语变音符号出现了一些问题:
$text = 'Ein schöner Text';
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
$text = trim($text, '-');
$text = iconv('utf-8', 'ASCII//TRANSLIT', $text);
$text = strtolower($text);
$text = preg_replace('~[^-\w]+~', '', $text);
结果应该是:'ein-schoener-text'
【问题讨论】: