本文整理汇总了PHP中Slug::noDiacritics方法的典型用法代码示例。如果您正苦于以下问题:PHP Slug::noDiacritics方法的具体用法?PHP Slug::noDiacritics怎么用?PHP Slug::noDiacritics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slug
的用法示例。
在下文中一共展示了Slug::noDiacritics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeSlugs
public static function makeSlugs($string, $maxlen = 0)
{
$newStringTab = array();
$string = strtolower(Slug::noDiacritics($string));
if (function_exists('str_split')) {
$stringTab = str_split($string);
} else {
$stringTab = my_str_split($string);
}
$numbers = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "-");
//$numbers=array("0","1","2","3","4","5","6","7","8","9");
foreach ($stringTab as $letter) {
if (in_array($letter, range("a", "z")) || in_array($letter, $numbers)) {
$newStringTab[] = $letter;
//print($letter);
} elseif ($letter == " ") {
$newStringTab[] = "-";
}
}
if (count($newStringTab)) {
$newString = implode($newStringTab);
if ($maxlen > 0) {
$newString = substr($newString, 0, $maxlen);
}
$newString = Slug::removeDuplicates('--', '-', $newString);
} else {
$newString = '';
}
return $newString;
}