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


PHP natsort函数代码示例

本文整理汇总了PHP中natsort函数的典型用法代码示例。如果您正苦于以下问题:PHP natsort函数的具体用法?PHP natsort怎么用?PHP natsort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getIcons

 public static function getIcons()
 {
     if (self::$icons === null) {
         $path = waConfig::get('wa_path_root') . '/wa-content/img/users/';
         if (!file_exists($path) || !is_dir($path)) {
             $list = array();
         }
         if (!($dh = opendir($path))) {
             $list = array();
         }
         $list = array();
         while (false !== ($file = readdir($dh))) {
             if ($file == '.' || $file == '..') {
                 continue;
             }
             if (is_dir($path . '/' . $file)) {
                 continue;
             } else {
                 $list[] = $file;
             }
         }
         closedir($dh);
         foreach ($list as &$l) {
             $p = strpos($l, '.png');
             if ($p !== false) {
                 $l = substr($l, 0, $p);
             }
         }
         unset($l);
         natsort($list);
         self::$icons = array_values($list);
     }
     return self::$icons;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:34,代码来源:waGroup.model.php

示例2: king_def

function king_def()
{
    global $king;
    $fields = array('notify_type', 'notify_id', 'notify_time', 'trade_no', 'out_trade_no', 'subject', 'body', 'price', 'discount', 'quantity', 'total_fee', 'payment_type', 'use_coupon', 'coupon_discount', 'is_total_fee_adjust', 'trade_status', 'refund_status', 'logistics_status', 'logistics_type', 'logistics_fee', 'logistics_payment', 'receive_name', 'receive_address', 'receive_zip', 'receive_phone', 'receive_mobile', 'seller_email', 'seller_id', 'buyer_id', 'buyer_email', 'gmt_create', 'gmt_payment', 'gmt_send_goods', 'gmt_refund', 'gmt_close', 'gmt_logistics_modify');
    natsort($fields);
    $array = array();
    foreach ($fields as $val) {
        if (isset($_POST[$val])) {
            //首先这些值需要先存在
            $array[] = $val . '=' . $_POST[$val];
        }
    }
    if (is_array($array)) {
        //万一不是数组就得输出错误提示
        $sign = md5(implode('&', $array) . $king->config('alipaykey', 'portal'));
        if ($sign != kc_post('sign')) {
            exit('fail');
        }
    } else {
        exit('fail');
    }
    /* 这里开始写数据更新过程 */
    switch (kc_post('trade_status')) {
        case 'WAIT_BUYER_PAY':
            $trade_status = 1;
            break;
        case 'WAIT_SELLER_SEND_GOODS':
            $trade_status = 3;
            break;
        case 'WAIT_BUYER_CONFIRM_GOODS':
            $trade_status = 4;
            break;
        case 'TRADE_FINISHED':
            $trade_status = 5;
            break;
        case 'TRADE_CLOSED':
            $trade_status = 10;
            break;
        case 'modify.tradeBase.totalFee':
            $trade_status = 11;
            break;
    }
    if (isset(kc_post('refund_status'))) {
        switch (kc_post('refund_status')) {
            case 'WAIT_SELLER_AGREE':
                $trade_status = 8;
                break;
            case 'REFUND_SUCCESS':
                $trade_status = 9;
                break;
            case 'REFUND_CLOSED':
                $trade_status = 10;
                break;
        }
    }
    $array = array('nstatus' => $trade_status, 'tid' => kc_post('trade_no'), 'buyer_id' => kc_post('buyer_email'), 'seller' => kc_post('seller_email'), 'paymethod' => 'alipay');
    $ono = kc_get('out_trade_no', 2, 1);
    $king->db->update('%s_orders', $array, "ono='{$ono}'");
    exit('success');
}
开发者ID:jonycookie,项目名称:projectm2,代码行数:60,代码来源:alipay.php

示例3: main

 public function main()
 {
     $db = ConnectionManager::getDataSource('default');
     $db->query($this->migrationsTableSql);
     $results = $db->query("select migrations from __migrations");
     $applied = array();
     foreach ($results as $result) {
         $applied[] = $result['__migrations']['migrations'];
     }
     $migrations = glob(APP . 'Config' . DS . 'Schema' . DS . 'migrations' . DS . '*.sql');
     natsort($migrations);
     $db->begin();
     try {
         foreach ($migrations as $filename) {
             list($migration, $ignore) = explode('.', basename($filename));
             if (in_array($migration, $applied)) {
                 continue;
             }
             $this->out("Migrating to {$migration}.");
             $db->query(file_get_contents($filename));
             $db->query("INSERT INTO `__migrations` VALUES ('{$migration}')");
         }
         $db->commit();
         $this->out('Done.');
     } catch (Exception $e) {
         $this->out("<error>Migration failed. Rolling back.</error>");
         $db->rollback();
         throw $e;
     }
 }
开发者ID:brianvoss,项目名称:jslate,代码行数:30,代码来源:MigrateShell.php

示例4: build_http_query

 public static function build_http_query($params = array())
 {
     if (empty($params)) {
         return "";
     }
     // Urlencode both keys and values
     $keys = Utility::urlencode_rfc3986(array_keys($params));
     $values = Utility::urlencode_rfc3986(array_values($params));
     $params = array_combine($keys, $values);
     // params are sorted by name, using lexicographical byte value ordering.
     // Ref: Spec: 9.1.1 (1)
     uksort($params, 'strcmp');
     $pairs = array();
     foreach ($params as $parameter => $value) {
         if (is_array($value)) {
             // If two or more params share the same name, they are sorted by their value
             // Ref: Spec: 9.1.1 (1)
             natsort($value);
             foreach ($value as $duplicate_value) {
                 $pairs[] = $parameter . '=' . $duplicate_value;
             }
         } else {
             $pairs[] = $parameter . '=' . $value;
         }
     }
     // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
     // Each name-value pair is separated by an '&' character (ASCII code 38)
     return implode('&', $pairs);
 }
开发者ID:johnshopkins,项目名称:twitterhook,代码行数:29,代码来源:Utility.php

示例5: getPublicKey

function getPublicKey($tab = array(), $mod, $e, $block_limit)
{
    $length_tab = count($tab);
    $public_key = array();
    $key_inv_mod = inv_mod($e, $mod);
    $password_permut = array();
    // if (super_croissance_check($tab)) {
    for ($i = 0; $i < $length_tab; $i++) {
        $current_operation = $tab[$i] * $e;
        $modulo_operation = my_modulo($current_operation, $mod);
        array_push($public_key, $modulo_operation);
    }
    // ordonée sans changer la valeur de la clé
    natsort($public_key);
    // on fait un foreach pour trouver les valeurs de la clé
    foreach ($public_key as $key => $value) {
        array_push($password_permut, $key);
    }
    echo "\n                Alice garde precieusement le mot de passe : [ ";
    foreach ($password_permut as $index_pass) {
        echo $index_pass;
    }
    echo " ]\n";
    // on sort en modifiant les valeurs de l'index
    sort($public_key);
    echo "\n                Alice envoie une clé publique à Bernard : [ ";
    foreach ($public_key as $values_in_key) {
        echo $values_in_key, " ";
    }
    echo " ]\n";
    echo "\n                Et envoie la limite de block à Bernard : [ ", $block_limit, " ]\n";
    return [$public_key, $password_permut];
    // }
}
开发者ID:saber-dev,项目名称:Math-1,代码行数:34,代码来源:keyCrypt.php

示例6: getCategories

 private function getCategories()
 {
     $category_models = Category::where('active', true)->where('category_id', 0)->orWhere('category_id', null)->orderBy('name')->get();
     $categories = $this->recursivePrint($category_models);
     natsort($categories);
     return $categories;
 }
开发者ID:redooor,项目名称:redminportal,代码行数:7,代码来源:CouponController.php

示例7: prepareResult

 /**
  * Result postprocessor, that transforms the results to hash.
  */
 protected function prepareResult($rows)
 {
     // Process ARRAY_KEY feature.
     if (is_array($rows) && $rows) {
         // Find ARRAY_KEY* AND PARENT_KEY fields in field list.
         $pk = null;
         $ak = array();
         foreach (current($rows) as $fieldName => $dummy) {
             if (0 == strncasecmp($fieldName, self::ALIAS_ARRAY_KEY, strlen(self::ALIAS_ARRAY_KEY))) {
                 $ak[] = $fieldName;
             } else {
                 if (0 == strncasecmp($fieldName, self::ALIAS_PARENT_KEY, strlen(self::ALIAS_PARENT_KEY))) {
                     $pk = $fieldName;
                 }
             }
         }
         natsort($ak);
         // sort ARRAY_KEY* using natural comparision
         if ($ak) {
             // Tree-based array? Fields: ARRAY_KEY, PARENT_KEY
             if ($pk !== null) {
                 return $this->prepareResult2Forest($rows, $ak[0], $pk);
             }
             // Key-based array? Fields: ARRAY_KEY.
             return $this->prepareResult2Hash($rows, $ak);
         }
     }
     return $rows;
 }
开发者ID:phoebius,项目名称:proof-of-concept,代码行数:32,代码来源:ResultWorkbench.class.php

示例8: getTeamspeakVersionsFromHTML

 function getTeamspeakVersionsFromHTML($htmlSource)
 {
     $teamspeakVersionArray = null;
     $dom = new DOMDocument();
     try {
         $dom->loadHTML($htmlSource);
         $tableElements = $dom->getElementsByTagName("tr");
         foreach ($tableElements as $tableElement) {
             foreach ($tableElement->childNodes as $tableChildElement) {
                 $tableElementValue = $tableChildElement->nodeValue;
                 //If an element ends with a forward slash then it is a directory
                 if (substr($tableElementValue, -1) == "/") {
                     $tableElementValue = substr($tableElementValue, 0, strlen($tableElementValue) - 1);
                     //Does the element match a version number?
                     if (preg_match("^((?:\\d+\\.)?(?:\\d+\\.)?\\d+\\.\\d+)\$^", $tableElementValue)) {
                         //Build array.
                         $teamspeakVersionArray[] = $tableElementValue;
                     }
                 }
             }
         }
     } catch (Exception $e) {
     }
     //Sort the array naturally
     natsort($teamspeakVersionArray);
     return $teamspeakVersionArray;
 }
开发者ID:kyroskoh,项目名称:Teamspeak3_LatestVersion,代码行数:27,代码来源:teamspeak.class.php

示例9: _buildQuery

 protected function _buildQuery($params, $separator = '&', $noQuotes = true, $subList = false)
 {
     if (empty($params)) {
         return '';
     }
     //encode both keys and values
     $keys = $this->_encode(array_keys($params));
     $values = $this->_encode(array_values($params));
     $params = array_combine($keys, $values);
     // Parameters are sorted by name, using lexicographical byte value ordering.
     // http://oauth.net/core/1.0/#rfc.section.9.1.1
     uksort($params, 'strcmp');
     // Turn params array into an array of "key=value" strings
     foreach ($params as $key => $value) {
         if (is_array($value)) {
             // If two or more parameters share the same name,
             // they are sorted by their value. OAuth Spec: 9.1.1 (1)
             natsort($value);
             $params[$key] = $this->_buildQuery($value, $separator, $noQuotes, true);
             continue;
         }
         if (!$noQuotes) {
             $value = '"' . $value . '"';
         }
         $params[$key] = $value;
     }
     if ($subList) {
         return $params;
     }
     foreach ($params as $key => $value) {
         $params[$key] = $key . '=' . $value;
     }
     return implode($separator, $params);
 }
开发者ID:brynner,项目名称:postr,代码行数:34,代码来源:base.php

示例10: index

 public function index()
 {
     $this->title($this('configuration'));
     $modules = array();
     foreach ($this->get_modules() as $module) {
         if ($module->administrable) {
             $modules[$module->name] = $module->get_title();
         }
     }
     natsort($modules);
     $langs = array();
     foreach (preg_grep('/\\.php$/', scandir('./neofrag/lang/')) as $file) {
         $lang = array();
         include './neofrag/lang/' . $file;
         $langs[substr($file, 0, -4)] = $lang['lang'];
     }
     natsort($langs);
     $this->load->library('form')->add_rules(array('name' => array('label' => $this('site_title'), 'value' => $this->config->nf_name, 'rules' => 'required'), 'description' => array('label' => $this('site_description'), 'value' => $this->config->nf_description, 'rules' => 'required'), 'contact' => array('label' => $this('contact_email'), 'value' => $this->config->nf_contact, 'type' => 'email', 'rules' => 'required'), 'default_page' => array('label' => $this('default_page'), 'values' => $modules, 'value' => $this->config->nf_default_page, 'type' => 'select', 'rules' => 'required'), 'default_language' => array('label' => $this('language'), 'values' => $langs, 'value' => $this->config->nf_default_language, 'type' => 'select', 'rules' => 'required'), 'humans_txt' => array('label' => '<a href="http://humanstxt.org/">humans.txt</a>', 'type' => 'textarea', 'value' => $this->config->nf_humans_txt), 'robots_txt' => array('label' => '<a href="http://www.robotstxt.org//">robots.txt</a>', 'type' => 'textarea', 'value' => $this->config->nf_robots_txt), 'analytics' => array('label' => $this('code_analytics'), 'type' => 'textarea', 'value' => $this->config->nf_analytics), 'debug' => array('label' => $this('debug_mode'), 'type' => 'radio', 'value' => $this->config->nf_debug, 'values' => array($this('debug_disabled'), $this('debug_errors_only'), $this('debug_full')))))->add_submit($this('save'))->display_required(FALSE);
     if ($this->form->is_valid($post)) {
         foreach ($post as $var => $value) {
             $this->config('nf_' . $var, $value);
         }
         refresh();
     }
     return new Panel(array('title' => $this('general_settings'), 'icon' => 'fa-cogs', 'content' => $this->form->display()));
 }
开发者ID:agreements,项目名称:neofrag-cms,代码行数:26,代码来源:admin.php

示例11: testInstaller

 /**
  * @test installing plugins
  */
 public function testInstaller()
 {
     $this->__cleanSystem();
     $this->assertTrue(App::import('lib', 'Installer.Installer'), 'Could not import the insatller lib');
     $this->assertTrue(App::import('Lib', 'Installer.ReleaseVersion'), 'Could not import Versions lib');
     $Installer = new InstallerLib();
     $Version = new ReleaseVersion(array('connection' => 'test_suite'));
     $connectionDetails = $Installer->cleanConnectionDetails(array('connection' => $this->db->config));
     $this->assertTrue($Installer->installPlugin($Version, $connectionDetails));
     $expected = array('0' => 'acos', '1' => 'aros', '2' => 'aros_acos', '3' => 'schema_migrations', '4' => 'sessions');
     $this->assertEqual($expected, $this->db->listSources());
     $this->assertTrue($Installer->installPlugin($Version, $connectionDetails, 'Installer'));
     $expected = array('0' => 'acos', '1' => 'aros', '2' => 'aros_acos', '3' => 'core_plugins', '4' => 'schema_migrations', '5' => 'sessions');
     $this->assertEqual($expected, $this->db->listSources());
     $pluginsToInstall = App::objects('plugin');
     natsort($pluginsToInstall);
     foreach ($pluginsToInstall as $k => $pluginToInstall) {
         if (in_array($pluginToInstall, array('Migrations'))) {
             continue;
         }
         $this->assertTrue($Installer->installPlugin($Version, $connectionDetails, $pluginToInstall), sprintf('%s could not be installed', $pluginToInstall));
     }
     foreach ($pluginsToInstall as $pluginToInstall) {
         $this->__checkVersionCount($pluginToInstall);
     }
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:29,代码来源:InstallerTest.php

示例12: twig_sort

 public function twig_sort($array, $method = 'asort', $sort_flag = 'SORT_REGULAR')
 {
     settype($sort_flag, 'integer');
     switch ($method) {
         case 'asort':
             asort($array, $sort_flag);
             break;
         case 'arsort':
             arsort($array, $sort_flag);
             break;
         case 'krsort':
             krsort($array, $sort_flag);
             break;
         case 'ksort':
             ksort($array, $sort_flag);
             break;
         case 'natcasesort':
             natcasesort($array);
             break;
         case 'natsort':
             natsort($array);
             break;
         case 'rsort':
             rsort($array, $sort_flag);
             break;
         case 'sort':
             sort($array, $sort_flag);
             break;
         case 'lastModifiedDate_desc':
             usort($array, array('App\\Respond\\Extensions\\BetterSortTwigExtension', 'lastModifiedDate_desc'));
             break;
     }
     return $array;
 }
开发者ID:YounessTayer,项目名称:respond,代码行数:34,代码来源:BetterSortTwigExtension.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filename = $input->getArgument('csv');
     $file = fopen($filename, 'r');
     $this->container = $this->getApplication()->getKernel()->getContainer();
     $om = $this->container->get('vib.doctrine.registry')->getManagerForClass('VIB\\CoreBundle\\Entity\\Entity');
     $vm = $this->container->get('vib.doctrine.registry')->getManagerForClass('VIB\\FliesBundle\\Entity\\Vial');
     $stocks = array();
     if ($file) {
         while ($data = fgetcsv($file, 0, "\t")) {
             $stocks[] = $data[0];
         }
     }
     natsort($stocks);
     $pdf = $this->container->get('vibfolks.pdflabel');
     foreach ($stocks as $stockname) {
         $qb = $om->getRepository('VIB\\FliesBundle\\Entity\\Stock')->createQueryBuilder('b');
         $qb->where('b.name like :term')->setParameter('term', $stockname);
         $stock = $qb->getQuery()->getSingleResult();
         echo $stock->getName() . "\n";
         foreach ($stock->getLivingVials() as $vial) {
             if (!$vial->isLabelPrinted()) {
                 echo "\t" . $vial . "\n";
                 $pdf->addLabel($vial);
                 $vm->markPrinted($vial);
             }
         }
     }
     $vm->flush();
     $jobStatus = $pdf->printPDF();
     echo $jobStatus . "\n";
 }
开发者ID:tchern0,项目名称:LabDB,代码行数:32,代码来源:PrintCommand.php

示例14: getSuggestionsResults

 /**
  * Return an array of suggestions from our Translation Memory API. Unlike
  * other services, we return values from both source and target languages.
  *
  * @param array  $source_strings Matches from source strings
  * @param array  $target_strings Matches from target strings
  * @param string $search         The string to search for
  * @param int    $max_results    Optional, default to 10, the max number of results we return
  *
  * @return array An array of strings
  */
 public static function getSuggestionsResults($source_strings, $target_strings, $search, $max_results = 10)
 {
     // Only interested in unique strings (values, not IDs).
     $data = ['source' => array_unique(array_values($source_strings)), 'target' => array_unique(array_values($target_strings))];
     $output = ['source' => [], 'target' => []];
     $flat_output = [];
     // Assign quality to each string in each group (source, target)
     foreach ($data as $group => $group_strings) {
         foreach ($group_strings as $single_string) {
             $quality = round(Strings::levenshteinQuality($search, $single_string), 2);
             $output[$group][$single_string] = $quality;
         }
     }
     // Determine how many suggestions we should display
     $limits = ['source' => $max_results / 2, 'target' => $max_results / 2];
     if (count($output['source']) < $limits['source']) {
         $limits['target'] = $max_results - count($output['source']);
     }
     if (count($output['target']) < $limits['target']) {
         $limits['source'] = $max_results - count($output['target']);
     }
     // Sort them by quality, display higher quality results first
     foreach ($output as $group => $group_strings) {
         natsort($group_strings);
         $suggestions = array_keys(array_reverse($group_strings));
         array_splice($suggestions, $limits[$group]);
         $flat_output = array_merge($flat_output, $suggestions);
     }
     return $flat_output;
 }
开发者ID:lester-shu,项目名称:transvision,代码行数:41,代码来源:ShowResults.php

示例15: test_natsort

 /**
  * @dataProvider unsortedArrayProvider
  */
 public function test_natsort($array)
 {
     $arr1 = $arr2 = $array;
     Arr($arr1)->natsort();
     natsort($arr2);
     $this->assertTrue($arr1 === $arr2);
 }
开发者ID:steefdw,项目名称:consistent-php,代码行数:10,代码来源:BasicArrSortTest.php


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