本文整理汇总了PHP中strcoll函数的典型用法代码示例。如果您正苦于以下问题:PHP strcoll函数的具体用法?PHP strcoll怎么用?PHP strcoll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strcoll函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testFetchTranslatedNamesSort
/**
* Test for the sort feature of country list
*/
public function testFetchTranslatedNamesSort()
{
$translatedCountriesList = array(
'FR' => 'France',
'GB' => 'Royaume-uni',
'DE' => 'Allemagne',
'NO' => 'Norvège' );
ezpINIHelper::setINISetting( array( 'fre-FR.ini', 'share/locale' ), 'CountryNames', 'Countries', $translatedCountriesList );
ezpINIHelper::setINISetting( 'site.ini', 'RegionalSettings', 'Locale', 'fre-FR' );
$countries = eZCountryType::fetchCountryList();
$this->assertInternalType( 'array', $countries, "eZCountryType::fetchCountryList() didn't return an array" );
$countryListIsSorted = true;
foreach( $countries as $country )
{
if ( !isset( $previousCountry ) )
{
$previousCountry = $country;
continue;
}
if ( strcoll( $previousCountry['Name'], $country['Name'] ) > 0 )
{
$countryListIsSorted = false;
break;
}
}
ezpINIHelper::restoreINISettings();
$this->assertTrue( $countryListIsSorted, "Country list isn't sorted" );
}
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:36,代码来源:ezcountrytype_test.php
示例2: postprocessDefinition
public static function postprocessDefinition(&$machine_def)
{
// Make sure the names are always set
if (!empty($machine_def['properties'])) {
foreach ($machine_def['properties'] as $p_name => &$property) {
if (empty($property['name'])) {
$property['name'] = $p_name;
}
}
unset($property);
}
if (!empty($machine_def['actions'])) {
foreach ($machine_def['actions'] as $a_name => &$action) {
if (empty($action['name'])) {
$action['name'] = $a_name;
}
}
unset($action);
// Sort actions, so they appear everywhere in defined order
// (readers may provide them in random order)
uasort($machine_def['actions'], function ($a, $b) {
$aw = isset($a['weight']) ? $a['weight'] : 50;
$bw = isset($b['weight']) ? $b['weight'] : 50;
if ($aw == $bw) {
return strcoll(isset($a['label']) ? $a['label'] : $a['name'], isset($b['label']) ? $b['label'] : $b['name']);
} else {
return $aw - $bw;
}
});
}
}
开发者ID:smalldb,项目名称:libsmalldb,代码行数:31,代码来源:JsonReader.php
示例3: cmp
private function cmp($aitem, $bitem)
{
if (!array_key_exists($this->_sortKey, $aitem)) {
return -$this->_sortVal;
} elseif (!array_key_exists($this->_sortKey, $bitem)) {
return -$this->_sortVal;
}
if (is_string($aitem[$this->_sortKey]) && is_string($bitem[$this->_sortKey])) {
return strcoll($aitem[$this->_sortKey], $bitem[$this->_sortKey]) * $this->_sortVal;
} else {
return $aitem[$this->_sortKey] > $bitem[$this->_sortKey] ? $this->_sortVal : -$this->_sortVal;
}
}
开发者ID:rollingwolf,项目名称:queryable-php,代码行数:13,代码来源:Result.php
示例4: _sortByName
/**
* Helper method for uasort to sort applications by name.
*
* @param string $a
* @param string $a
*
* @return integer
*/
protected function _sortByName($a, $b)
{
return strcoll(_($a['name']), _($b['name']));
}
开发者ID:jubinpatel,项目名称:horde,代码行数:12,代码来源:Topbar.php
示例5: strCmp
/**
* Compare two strings
*/
function strCmp($a, $b)
{
global $ilCollator;
if (is_object($ilCollator)) {
return $ilCollator->compare(ilStr::strToUpper($a), ilStr::strToUpper($b)) > 0;
} else {
return strcoll(ilStr::strToUpper($a), ilStr::strToUpper($b)) > 0;
}
}
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:12,代码来源:class.ilStr.php
示例6: sort_folder_comparator
/**
* Callback for uasort() that implements correct
* locale-aware case-sensitive sorting
*/
protected function sort_folder_comparator($str1, $str2)
{
$path1 = explode($this->delimiter, $str1);
$path2 = explode($this->delimiter, $str2);
foreach ($path1 as $idx => $folder1) {
$folder2 = $path2[$idx];
if ($folder1 === $folder2) {
continue;
}
return strcoll($folder1, $folder2);
}
}
开发者ID:ehabqino,项目名称:roundcubemail,代码行数:16,代码来源:rcube_imap.php
示例7: compare_definitions_by_name
/**
* Compare function for ordering by name in order_definitions().
*
* @param $first WPCF_Field_Definition_Abstract
* @param $second WPCF_Field_Definition_Abstract
*
* @return int
*/
public function compare_definitions_by_name($first, $second)
{
return strcoll(strtolower($first->get_name()), strtolower($second->get_name()));
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:12,代码来源:definition_factory.php
示例8: strcmp_lok
function strcmp_lok($teksto1, $teksto2)
{
return strcoll($teksto1, $teksto2);
}
开发者ID:BackupTheBerlios,项目名称:aligilo-svn,代码行数:4,代码来源:iloj_listo.php
示例9: _sortByNotepad
/**
* Comparison function for sorting notes by notepad name.
*
* @param array $a Note one.
* @param array $b Note two.
*
* @return integer 1 if note one is greater, -1 if note two is greater;
* 0 if they are equal.
*/
protected static function _sortByNotepad($a, $b)
{
$aowner = $a['memolist_id'];
$bowner = $b['memolist_id'];
$ashare = $GLOBALS['mnemo_shares']->getShare($aowner);
$bshare = $GLOBALS['mnemo_shares']->getShare($bowner);
if ($aowner != $ashare->get('owner')) {
$aowner = $ashare->get('name');
}
if ($bowner != $bshare->get('owner')) {
$bowner = $bshare->get('name');
}
return strcoll($aowner, $bowner);
}
开发者ID:jubinpatel,项目名称:horde,代码行数:23,代码来源:Mnemo.php
示例10: setlocale
<?php
setlocale(LC_COLLATE, 'NL');
echo strcoll("Hello World!", "Hello World!");
echo "<br>";
setlocale(LC_COLLATE, 'en_US');
echo strcoll("Hello World!", "Hello World!");
开发者ID:kshark27,项目名称:Violist,代码行数:7,代码来源:strcoll.php
示例11: _sortCategoryArrayByName
protected function _sortCategoryArrayByName($a, $b)
{
return strcoll($a->getName(), $b->getName());
}
开发者ID:TheTypoMaster,项目名称:magento,代码行数:4,代码来源:Navigation.php
示例12: _sort
/**
* Helper method to sort an array of tickets.
*
* Used as callback to usort().
*
* @param array $a The first ticket to compare.
* @param array $b The second ticket to compare.
* @param string $sortby The field to sort by. If null, uses the field
* from self::sortBy().
* @param string $sortdir The direction to sort. If null, uses the value
* from self::sortDir().
*
* @return integer
*/
protected static function _sort($a, $b, $sortby = null, $sortdir = null)
{
if (is_null($sortby)) {
$sortby = self::$_sortBy;
}
if (is_null($sortdir)) {
$sortdir = self::$_sortDir;
}
if (is_array($sortby)) {
if (!isset($a[$sortby[0]])) {
$a[$sortby[0]] = null;
}
if (!isset($b[$sortby[0]])) {
$b[$sortby[0]] = null;
}
if (!count($sortby)) {
return 0;
}
if ($a['sort_by'][$sortby[0]] > $b['sort_by'][$sortby[0]]) {
return $sortdir[0] ? -1 : 1;
}
if ($a['sort_by'][$sortby[0]] === $b['sort_by'][$sortby[0]]) {
array_shift($sortby);
array_shift($sortdir);
return self::_sort($a, $b, $sortby, $sortdir);
}
return $sortdir[0] ? 1 : -1;
}
$a_val = isset($a['sort_by'][$sortby]) ? $a['sort_by'][$sortby] : null;
$b_val = isset($b['sort_by'][$sortby]) ? $b['sort_by'][$sortby] : null;
// Take care of the simplest case first
if ($a_val === $b_val) {
return 0;
}
if ((is_numeric($a_val) || is_null($a_val)) && (is_numeric($b_val) || is_null($b_val))) {
// Numeric comparison
return (int) ($sortdir ? $b_val > $a_val : $a_val > $b_val);
}
// Some special case sorting
if (is_array($a_val) || is_array($b_val)) {
$a_val = implode('', $a_val);
$b_val = implode('', $b_val);
}
// String comparison
return $sortdir ? strcoll($b_val, $a_val) : strcoll($a_val, $b_val);
}
开发者ID:jubinpatel,项目名称:horde,代码行数:60,代码来源:Whups.php
示例13: coll
/**
* (PHP 4 >= 4.0.5, PHP 5)<br/>
* Locale based string comparison
* @link http://php.net/manual/en/function.strcoll.php
* @param string $string1 <p>
* The first string.
* </p>
* @param string $string2 <p>
* The second string.
* </p>
* @return int < 0 if <i>string1</i> is less than
* <i>string2</i>; > 0 if
* <i>string1</i> is greater than
* <i>string2</i>, and 0 if they are equal.
*/
static function coll($string1, $string2)
{
return strcoll($string1, $string2);
}
开发者ID:steefdw,项目名称:consistent-php,代码行数:19,代码来源:Str.php
示例14: sort_func
/**
* sub-function to sort an array
*
* @param array $a
* @param array $b
*
* @return boolean true on success / false on error
* @static
*
*/
public static function sort_func($a, $b)
{
global $array_sortby, $array_sortorder;
// this comparison should give optimal results if
// locale is provided and mb string functions are supported
if ($array_sortorder == "asc") {
return ilStr::strCmp($a[$array_sortby], $b[$array_sortby]);
}
if ($array_sortorder == "desc") {
return !ilStr::strCmp($a[$array_sortby], $b[$array_sortby]);
return strcoll(ilStr::strToUpper($b[$array_sortby]), ilStr::strToUpper($a[$array_sortby]));
}
}
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:23,代码来源:class.ilUtil.php
示例15: _sortEventStartTime
/**
* Used with usort() to sort events based on their start times.
*/
protected static function _sortEventStartTime($a, $b)
{
$diff = $a->start->compareDateTime($b->start);
if ($diff == 0) {
return strcoll($a->title, $b->title);
} else {
return $diff;
}
}
开发者ID:AsylumCorp,项目名称:horde,代码行数:12,代码来源:Kronolith.php
示例16: compare
/**
* The comparison function used to sort the elements
*
* @param mixed $a an element in the list
* @param mixed $b an element in the list
* @return int
*/
public function compare($a, $b)
{
if ($this->_dir === SORT_ASC) {
list($a, $b) = [$b, $a];
}
$callback = $this->_callback;
$a = $callback($a);
$b = $callback($b);
if ($this->_type === SORT_NUMERIC) {
return $a - $b;
}
if ($this->_type === SORT_NATURAL) {
return strnatcmp($a, $b);
}
if ($this->_type === SORT_STRING) {
return strcmp($a, $b);
}
return strcoll($a, $b);
}
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:26,代码来源:SortIterator.php
示例17: asearch_unhtml_strcoll
/**
* @param string $a
* @param string $b
* @return bool strcoll()-like result
*/
function asearch_unhtml_strcoll($a, $b)
{
return strcoll(asearch_unhtmlentities($a), asearch_unhtmlentities($b));
}
开发者ID:BackupTheBerlios,项目名称:hpt-obm-svn,代码行数:9,代码来源:search.php
示例18: myCompare
/**
* Compare two strings or numbers. Return values as strcmp().
**/
function myCompare($arrA, $arrB, $caseSensitive = false)
{
$a = $arrA[$_GET["sort"]];
$b = $arrB[$_GET["sort"]];
// sort .. first
if ($arrA["isBack"]) {
return -1;
}
if ($arrB["isBack"]) {
return 1;
}
// sort directories above everything else
if ($arrA["isDirectory"] != $arrB["isDirectory"]) {
$result = $arrB["isDirectory"] - $arrA["isDirectory"];
} else {
if ($arrA["isDirectory"] && $arrB["isDirectory"] && ($_GET["sort"] == "type" || $_GET["sort"] == "size")) {
$result = 0;
} else {
if (is_string($a) or is_string($b)) {
if (!$caseSensitive) {
$a = strtoupper($a);
$b = strtoupper($b);
}
$result = strcoll($a, $b);
} else {
$result = $a - $b;
}
}
}
if (strtolower($_GET["order"]) == "desc") {
return -$result;
} else {
return $result;
}
}
开发者ID:stsquad,项目名称:CODEF,代码行数:38,代码来源:index.php
示例19: _sortCategoryArrayByName
/**
* Sorting Method
*
* @param Mage_Catalog_Model_Category $arg1
* @param Mage_Catalog_Model_Category $arg2
* @return int
* @deprecated
*/
protected function _sortCategoryArrayByName($arg1, $arg2)
{
return strcoll($arg1->getName(), $arg2->getName());
}
开发者ID:gruenspar,项目名称:VertNav,代码行数:12,代码来源:Navigation.php
示例20: getFacetList
/**
* Get a list of items from a facet.
*
* @param string $facet which facet we're searching in
* @param string $category which subfacet the search applies to
* @param string $sort how are we ranking these? || 'index'
* @param string $query is there a specific query? No = wildcard
*
* @return array Array indexed by value with text of displayText and
* count
*/
protected function getFacetList($facet, $category = null, $sort = 'count', $query = '[* TO *]')
{
$results = $this->getServiceLocator()->get('VuFind\\SearchResultsPluginManager')->get('Solr');
$params = $results->getParams();
$params->addFacet($facet);
if ($category != null) {
$query = $category . ':' . $query;
} else {
$query = $facet . ':' . $query;
}
$params->setOverrideQuery($query);
$params->getOptions()->disableHighlighting();
$params->getOptions()->spellcheckEnabled(false);
// Get limit from config
$params->setFacetLimit($this->config->Browse->result_limit);
$params->setLimit(0);
// Facet prefix
if ($this->params()->fromQuery('facet_prefix')) {
$params->setFacetPrefix($this->params()->fromQuery('facet_prefix'));
}
$params->setFacetSort($sort);
$result = $results->getFacetList();
if (isset($result[$facet])) {
// Sort facets alphabetically if configured to do so:
if (isset($this->config->Browse->alphabetical_order) && $this->config->Browse->alphabetical_order) {
$callback = function ($a, $b) {
return strcoll($a['displayText'], $b['displayText']);
};
usort($result[$facet]['list'], $callback);
}
return $result[$facet]['list'];
} else {
return [];
}
}
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:46,代码来源:BrowseController.php
注:本文中的strcoll函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论