本文整理汇总了PHP中PerchUtil::urlify_non_translit方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::urlify_non_translit方法的具体用法?PHP PerchUtil::urlify_non_translit怎么用?PHP PerchUtil::urlify_non_translit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchUtil
的用法示例。
在下文中一共展示了PerchUtil::urlify_non_translit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: urlify
public static function urlify($string, $spacer = '-')
{
$string = trim($string);
$string = htmlspecialchars_decode($string, ENT_QUOTES);
$string = strip_tags($string);
$string = str_replace(array('$', '£', '€', '™', '®', '|'), array('', 'GBP ', 'EUR ', 'tm', 'r', ''), $string);
$string = preg_replace('#(\\d)\\.(\\d)#', '$1 $2', $string);
// make sure numbers with decimals don't mislead, e.g. 2.5 -> 25
$tranliterator_rule = 'Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();';
if (function_exists('transliterator_list_ids')) {
if (in_array('Latin-ASCII', transliterator_list_ids())) {
$tranliterator_rule = 'Any-Latin; Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();';
}
}
if (function_exists('transliterator_transliterate')) {
$string = str_replace('-', ' ', $string);
$s = transliterator_transliterate($tranliterator_rule, $string);
} else {
if (class_exists('Transliterator')) {
$string = str_replace('-', ' ', $string);
$T = Transliterator::create($tranliterator_rule);
$s = $T->transliterate($string);
} else {
$s = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
$s = strtolower($s);
$s = preg_replace('/[^a-z0-9\\-\\s]/', '', $s);
}
}
$s = preg_replace('/[\\s\\-]+/', $spacer, $s);
if (strlen($s) > 0) {
return $s;
} else {
return PerchUtil::urlify_non_translit($string);
}
}