当前位置: 首页>>代码示例>>PHP>>正文


PHP Collator::asort方法代码示例

本文整理汇总了PHP中Collator::asort方法的典型用法代码示例。如果您正苦于以下问题:PHP Collator::asort方法的具体用法?PHP Collator::asort怎么用?PHP Collator::asort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collator的用法示例。


在下文中一共展示了Collator::asort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAsortIntl

 /**
  * @dataProvider asortProvider
  */
 public function testAsortIntl($array, $sortFlag, $expected)
 {
     $this->skipIfIntlExtensionIsNotLoaded();
     $collator = new \Collator('en');
     $collator->asort($array, $sortFlag);
     $this->assertSame($expected, $array);
 }
开发者ID:laubosslink,项目名称:lab,代码行数:10,代码来源:StubCollatorTest.php

示例2: sortByValue

 protected function sortByValue($collection)
 {
     $collator = new \Collator('fr_FR');
     $items = iterator_to_array($collection);
     $collator->asort($items);
     return new Map($items);
 }
开发者ID:polem,项目名称:departements,代码行数:7,代码来源:AbstractDatasource.php

示例3: _sortString

 /**
  * Sort an array of strings based on current locale.
  *
  * @param array &$sorted  Array of strings.
  */
 protected function _sortString(&$sorted)
 {
     if (empty($this->_collator)) {
         asort($sorted, SORT_LOCALE_STRING);
     } else {
         $this->_collator->asort($sorted, Collator::SORT_STRING);
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:13,代码来源:ClientSort.php

示例4: getCurrencyNames

 /**
  * {@inheritdoc}
  */
 public function getCurrencyNames($locale = null)
 {
     if (null === $locale) {
         $locale = \Locale::getDefault();
     }
     $names = parent::getCurrencyNames($locale);
     $collator = new \Collator($locale);
     $collator->asort($names);
     return $names;
 }
开发者ID:sanborino,项目名称:clinica,代码行数:13,代码来源:IcuCurrencyBundle.php

示例5: getScriptNames

 /**
  * {@inheritdoc}
  */
 public function getScriptNames($locale = null)
 {
     if (null === $locale) {
         $locale = \Locale::getDefault();
     }
     $scripts = parent::getScriptNames($locale);
     $collator = new \Collator($locale);
     $collator->asort($scripts);
     return $scripts;
 }
开发者ID:sanborino,项目名称:clinica,代码行数:13,代码来源:IcuLanguageBundle.php

示例6: testGetNames

 /**
  * @dataProvider provideLocales
  */
 public function testGetNames($displayLocale)
 {
     $names = $this->dataProvider->getNames($displayLocale);
     $keys = array_keys($names);
     sort($keys);
     $this->assertEquals(static::$currencies, $keys);
     // Names should be sorted
     $sortedNames = $names;
     $collator = new \Collator($displayLocale);
     $collator->asort($names);
     $this->assertSame($sortedNames, $names);
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:15,代码来源:AbstractCurrencyDataProviderTest.php

示例7: getNames

 public function getNames($displayLocale = null)
 {
     if (null === $displayLocale) {
         $displayLocale = Locale::getDefault();
     }
     $names = $this->reader->readEntry($this->path, $displayLocale, array('Names'));
     if ($names instanceof \Traversable) {
         $names = iterator_to_array($names);
     }
     $collator = new \Collator($displayLocale);
     $collator->asort($names);
     return $names;
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:13,代码来源:ScriptDataProvider.php

示例8: getDisplayLanguages

 /**
  * Returns the language names for a locale
  *
  * @param  string $locale     The locale to use for the language names
  * @return array              The language names with their codes as keys
  * @throws RuntimeException   When the resource bundles cannot be loaded
  */
 public static function getDisplayLanguages($locale)
 {
     if (!isset(self::$languages[$locale])) {
         $bundle = new \ResourceBundle($locale, __DIR__ . '/Resources/data/lang');
         if (null === $bundle) {
             throw new \RuntimeException('The language resource bundle could not be loaded');
         }
         $collator = new \Collator($locale);
         $languages = array();
         foreach ($bundle->get('Languages') as $code => $name) {
             // "mul" is the code for multiple languages
             if ('mul' !== $code) {
                 $languages[$code] = $name;
             }
         }
         $collator->asort($languages);
         self::$languages[$locale] = $languages;
     }
     return self::$languages[$locale];
 }
开发者ID:spf13,项目名称:symfony,代码行数:27,代码来源:Locale.php

示例9: sort

 /**
  * @param array $array
  * @param bool $keepKeys
  *
  * @return array
  */
 public function sort(&$array, $keepKeys = false)
 {
     $me = $this;
     if ($keepKeys) {
         if (isset($this->collator)) {
             $result = $this->collator->asort($array);
         } else {
             $result = uasort($array, function ($a, $b) use($me) {
                 return $me->compare($a, $b);
             });
         }
     } else {
         if (isset($this->collator)) {
             $result = $this->collator->sort($array);
         } else {
             $result = usort($array, function ($a, $b) use($me) {
                 return $me->compare($a, $b);
             });
         }
     }
     return $result;
 }
开发者ID:win10calendar,项目名称:3rdparty,代码行数:28,代码来源:Comparer.php

示例10: getCountryNames

 /**
  * {@inheritdoc}
  */
 public function getCountryNames($locale = null)
 {
     if (null === $locale) {
         $locale = \Locale::getDefault();
     }
     $countries = parent::getCountryNames($locale);
     // "ZZ" is the code for unknown country
     unset($countries['ZZ']);
     // Global countries (f.i. "America") have numeric codes
     // Countries have alphabetic codes
     foreach ($countries as $code => $name) {
         // is_int() does not work, since some numbers start with '0' and
         // thus are stored as strings.
         // The (string) cast is necessary since ctype_digit() returns false
         // for integers.
         if (ctype_digit((string) $code)) {
             unset($countries[$code]);
         }
     }
     $collator = new \Collator($locale);
     $collator->asort($countries);
     return $countries;
 }
开发者ID:sanborino,项目名称:clinica,代码行数:26,代码来源:IcuRegionBundle.php

示例11: sortData

 /**
  * Sorts the data array for a given locale, using the locale translations.
  * It is UTF-8 aware if the Collator class is available (requires the intl
  * extension).
  *
  * @param string $locale  The locale whose collation rules should be used.
  * @param array  $data    Array of strings to sort.
  * @return array          The $data array, sorted.
  */
 protected function sortData($locale, $data)
 {
     $locale = $this->_getLocale($locale);
     if (is_array($data)) {
         if (class_exists('Collator')) {
             $collator = new \Collator($locale);
             $collator->asort($data);
         } else {
             asort($data);
         }
     }
     return $data;
 }
开发者ID:tariq86,项目名称:country-list,代码行数:22,代码来源:CountryList.php

示例12: COUNT

            //integer from string
            $pref = cms_db_prefix();
            $fillers = str_repeat('?,', $vc - 1) . '?';
            $sql = 'SELECT COUNT(1) AS num FROM ' . $pref . 'module_tmt_groups WHERE group_id IN (' . $fillers . ') AND flags = 0';
            $inact = $db->GetOne($sql, $vals);
            $toggled = $inact !== FALSE && (int) $inact == 0 ? '0' : '1';
            $sql = 'UPDATE ' . $pref . 'module_tmt_groups SET flags=' . $toggled . ' WHERE group_id IN (' . $fillers . ')';
            $db->Execute($sql, $vals);
        }
    }
} elseif (isset($params['sort'])) {
    if (version_compare(PHP_VERSION, '5.3.0') >= 0 && extension_loaded('intl')) {
        $locale = setlocale(LC_COLLATE, '0');
        //TODO
        $cl = new Collator($locale);
        $cl->asort($params['group_name'], Collator::SORT_STRING);
    } else {
        asort($params['group_name'], SORT_LOCALE_STRING);
    }
    //probably too bad about i18n
    $ord = 1;
    $pref = cms_db_prefix();
    $sql = 'UPDATE ' . $pref . 'module_tmt_groups SET displayorder=? WHERE group_id=?';
    foreach ($params['group_name'] as $indx => &$name) {
        $id = (int) $params['group_active'][$indx];
        $db->Execute($sql, array($ord, $id));
        $ord++;
    }
    unset($name);
}
$this->Redirect($id, 'defaultadmin', '', array('showtab' => 1));
开发者ID:kleitz,项目名称:CMSMS-Tourney-Module,代码行数:31,代码来源:action.process_groups.php

示例13: getAbsence

 public function getAbsence()
 {
     $data = $this->getData();
     if ($data != false) {
         $header = array();
         $items = array();
         $other = array();
         $first = true;
         $count = count($data);
         foreach ($data as $value) {
             $value = html_entity_decode(trim($value));
             if ($first) {
                 $header = mb_strtolower($value, 'UTF-8');
                 $header = ucfirst($header);
                 if ($count == 1) {
                     array_push($items, $this->msg);
                 }
                 $first = false;
             } else {
                 if (preg_match("/\\([\\w\\W]+[\\w\\W]+[\\w\\W]\\)/", $value)) {
                     array_push($items, $value);
                 } else {
                     array_push($other, $value);
                 }
             }
         }
         // Sort items alphabetically
         $col = new \Collator('is_IS');
         $col->asort($items);
         $items = array_values($items);
     } else {
         $header = $this->problem;
     }
     return array('header' => $header, 'items' => $items, 'other' => $other);
 }
开发者ID:haukur46,项目名称:vma,代码行数:35,代码来源:vma.php

示例14: get_data

function get_data($index, $dataDir, $locale = 'en', $constraint = null)
{
    $data = array();
    $bundle = load_resource_bundle($locale, $dataDir);
    foreach ($bundle->get($index) as $code => $name) {
        if (null !== $constraint) {
            if ($constraint($code)) {
                $data[$code] = $name;
            }
            continue;
        }
        $data[$code] = $name;
    }
    $collator = new \Collator($locale);
    $collator->asort($data);
    return $data;
}
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:17,代码来源:build-data.php

示例15: getDisplayLocales

    /**
     * Returns the locale names for a locale
     *
     * @param  string $locale     The locale to use for the locale names
     * @return array              The locale names with their codes as keys
     * @throws RuntimeException   When the resource bundles cannot be loaded
     */
    static public function getDisplayLocales($locale)
    {
        if (!isset(self::$locales[$locale])) {
            $bundle = \ResourceBundle::create($locale, __DIR__.'/Resources/data/names');

            if (null === $bundle) {
                throw new \RuntimeException('The locale resource bundle could not be loaded');
            }

            $collator = new \Collator($locale);
            $locales = array();

            foreach ($bundle->get('Locales') as $code => $name) {
                $locales[$code] = $name;
            }

            $collator->asort($locales);

            self::$locales[$locale] = $locales;
        }

        return self::$locales[$locale];
    }
开发者ID:usefulthink,项目名称:symfony,代码行数:30,代码来源:Locale.php


注:本文中的Collator::asort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。