本文整理汇总了PHP中false::asort方法的典型用法代码示例。如果您正苦于以下问题:PHP false::asort方法的具体用法?PHP false::asort怎么用?PHP false::asort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类false
的用法示例。
在下文中一共展示了false::asort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: asort
/**
* Locale aware sorting, the key associations are kept, values are sorted alphabetically.
*
* @param array $arr array to be sorted (reference)
* @param int $sortflag One of Collator::SORT_REGULAR, Collator::SORT_NUMERIC, Collator::SORT_STRING
* @return void modifies parameter
*/
public static function asort(array &$arr, $sortflag = null) {
if (self::ensure_collator_available()) {
if (!isset($sortflag)) {
$sortflag = Collator::SORT_REGULAR;
}
self::$collator->asort($arr, $sortflag);
return;
}
asort($arr, SORT_LOCALE_STRING);
}
示例2: asort
/**
* Locale aware sorting, the key associations are kept, values are sorted alphabetically.
*
* @param array $arr array to be sorted (reference)
* @param int $sortflag One of collatorlib::SORT_NUMERIC, collatorlib::SORT_STRING, collatorlib::SORT_NATURAL, collatorlib::SORT_REGULAR
* optionally "|" collatorlib::CASE_SENSITIVE
* @return bool True on success
*/
public static function asort(array &$arr, $sortflag = collatorlib::SORT_STRING)
{
if (empty($arr)) {
// nothing to do
return true;
}
$original = null;
$casesensitive = (bool) ($sortflag & collatorlib::CASE_SENSITIVE);
$sortflag = $sortflag & ~collatorlib::CASE_SENSITIVE;
if ($sortflag != collatorlib::SORT_NATURAL and $sortflag != collatorlib::SORT_STRING) {
$casesensitive = false;
}
if (self::ensure_collator_available()) {
if ($sortflag == collatorlib::SORT_NUMERIC) {
$flag = Collator::SORT_NUMERIC;
} else {
if ($sortflag == collatorlib::SORT_REGULAR) {
$flag = Collator::SORT_REGULAR;
} else {
$flag = Collator::SORT_STRING;
}
}
if ($sortflag == collatorlib::SORT_NATURAL) {
$original = $arr;
if ($sortflag == collatorlib::SORT_NATURAL) {
foreach ($arr as $key => $value) {
$arr[$key] = self::naturalise((string) $value);
}
}
}
if ($casesensitive) {
self::$collator->setAttribute(Collator::CASE_FIRST, Collator::UPPER_FIRST);
} else {
self::$collator->setAttribute(Collator::CASE_FIRST, Collator::OFF);
}
$result = self::$collator->asort($arr, $flag);
if ($original) {
self::restore_array($arr, $original);
}
return $result;
}
// try some fallback that works at least for English
if ($sortflag == collatorlib::SORT_NUMERIC) {
return asort($arr, SORT_NUMERIC);
} else {
if ($sortflag == collatorlib::SORT_REGULAR) {
return asort($arr, SORT_REGULAR);
}
}
if (!$casesensitive) {
$original = $arr;
foreach ($arr as $key => $value) {
$arr[$key] = textlib::strtolower($value);
}
}
if ($sortflag == collatorlib::SORT_NATURAL) {
$result = natsort($arr);
} else {
$result = asort($arr, SORT_LOCALE_STRING);
}
if ($original) {
self::restore_array($arr, $original);
}
return $result;
}