本文整理匯總了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;
}