本文整理匯總了PHP中Slug::removeDuplicates方法的典型用法代碼示例。如果您正苦於以下問題:PHP Slug::removeDuplicates方法的具體用法?PHP Slug::removeDuplicates怎麽用?PHP Slug::removeDuplicates使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Slug
的用法示例。
在下文中一共展示了Slug::removeDuplicates方法的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;
}