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


PHP krsort函数代码示例

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


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

示例1: afterExample

 public function afterExample(ExampleEvent $event)
 {
     $total = $this->stats->getEventsCount();
     $counts = $this->stats->getCountsHash();
     $percents = array_map(function ($count) use($total) {
         return round($count / ($total / 100), 0);
     }, $counts);
     $lengths = array_map(function ($percent) {
         return round($percent / 2, 0);
     }, $percents);
     $size = 50;
     asort($lengths);
     $progress = array();
     foreach ($lengths as $status => $length) {
         $text = $percents[$status] . '%';
         $length = $size - $length >= 0 ? $length : $size;
         $size = $size - $length;
         if ($length > strlen($text) + 2) {
             $text = str_pad($text, $length, ' ', STR_PAD_BOTH);
         } else {
             $text = str_pad('', $length, ' ');
         }
         $progress[$status] = sprintf("<{$status}-bg>%s</{$status}-bg>", $text);
     }
     krsort($progress);
     $this->printException($event, 2);
     $this->io->writeTemp(implode('', $progress) . ' ' . $total);
 }
开发者ID:phpspec,项目名称:phpspec2,代码行数:28,代码来源:ProgressFormatter.php

示例2: special

 function special()
 {
     $page_title = strtolower($this->request->params['wikipage']);
     switch ($page_title) {
         // show pages index, sorted by title
         case 'page_index':
         case 'date_index':
             // eager load information about last updates, without loading text
             $this->Wiki->WikiPage->recursive = -1;
             $options = array('conditions' => array('WikiPage.wiki_id' => $this->Wiki->field('id')), 'fields' => 'WikiPage.*, WikiContent.updated_on', 'joins' => array(array("type" => 'LEFT', "table" => 'wiki_contents', "alias" => 'WikiContent', "conditions" => 'WikiContent.page_id=WikiPage.id')), 'order' => 'WikiPage.title');
             //'order' => 'Content.updated_on DESC');
             $pages = $this->Wiki->WikiPage->find('all', $options);
             $this->set('pages', $pages);
             // 以下、viewのための整形
             foreach ($pages as $page) {
                 $day = date('Y-m-d', strtotime($page['WikiContent']['updated_on']));
                 $pages_by_date[$day][] = $page;
             }
             krsort($pages_by_date);
             $this->set('pages_by_date', $pages_by_date);
             break;
         case 'export':
             $this->render("export_multiple");
             // temporary implementation. fixme.
             return;
             break;
         default:
             // requested special page doesn't exist, redirect to default page
             $this->redirect(array('controller' => 'wiki', 'action' => 'index', 'project_id' => $this->request->params['project_id'], 'wikipage' => null));
             break;
     }
     $this->render("special_{$page_title}");
 }
开发者ID:ha1t,项目名称:candycane,代码行数:33,代码来源:WikiController.php

示例3: Filllogs

function Filllogs()
{
    $logsFile = $GLOBALS["LOG_FILE"];
    $t = explode("\n", @file_get_contents($logsFile));
    krsort($t);
    echo @implode("\n", $t);
}
开发者ID:articatech,项目名称:artica,代码行数:7,代码来源:Kav4Proxy.license.progress.php

示例4: testAuthenticationCollector

 /**
  * Tests adding, getting, and order of priorities.
  *
  * @covers ::addProvider
  * @covers ::getSortedProviders
  * @covers ::getProvider
  * @covers ::isGlobal
  */
 public function testAuthenticationCollector()
 {
     $providers = [];
     $global = [];
     $authentication_collector = new AuthenticationCollector();
     $priorities = [2, 0, -8, 10, 1, 3, -5, 0, 6, -10, -4];
     foreach ($priorities as $priority) {
         $provider_id = $this->randomMachineName();
         $provider = new TestAuthenticationProvider($provider_id);
         $providers[$priority][$provider_id] = $provider;
         $global[$provider_id] = rand(0, 1) > 0.5;
         $authentication_collector->addProvider($provider, $provider_id, $priority, $global[$provider_id]);
     }
     // Sort the $providers array by priority (highest number is lowest priority)
     // and compare with AuthenticationCollector::getSortedProviders().
     krsort($providers);
     // Merge nested providers from $providers into $sorted_providers.
     $sorted_providers = [];
     foreach ($providers as $providers_priority) {
         $sorted_providers = array_merge($sorted_providers, $providers_priority);
     }
     $this->assertEquals($sorted_providers, $authentication_collector->getSortedProviders());
     // Test AuthenticationCollector::getProvider() and
     // AuthenticationCollector::isGlobal().
     foreach ($sorted_providers as $provider) {
         $this->assertEquals($provider, $authentication_collector->getProvider($provider->providerId));
         $this->assertEquals($global[$provider->providerId], $authentication_collector->isGlobal($provider->providerId));
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:37,代码来源:AuthenticationCollectorTest.php

示例5: getFullHistory

 /**
  * Compose and get order full history.
  * Consists of the status history comments as well as of invoices, shipments and creditmemos creations
  * @return array
  */
 public function getFullHistory()
 {
     $order = $this->getOrder();
     $history = array();
     foreach ($order->getAllStatusHistory() as $orderComment) {
         $history[$orderComment->getEntityId()] = $this->_prepareHistoryItem($orderComment->getStatusLabel(), $orderComment->getIsCustomerNotified(), $orderComment->getCreatedAtDate(), $orderComment->getComment());
     }
     foreach ($order->getCreditmemosCollection() as $_memo) {
         $history[$_memo->getEntityId()] = $this->_prepareHistoryItem($this->__('Credit memo #%s created', $_memo->getIncrementId()), $_memo->getEmailSent(), $_memo->getCreatedAtDate());
         foreach ($_memo->getCommentsCollection() as $_comment) {
             $history[$_comment->getEntityId()] = $this->_prepareHistoryItem($this->__('Credit memo #%s comment added', $_memo->getIncrementId()), $_comment->getIsCustomerNotified(), $_comment->getCreatedAtDate(), $_comment->getComment());
         }
     }
     foreach ($order->getShipmentsCollection() as $_shipment) {
         $history[$_shipment->getEntityId()] = $this->_prepareHistoryItem($this->__('Shipment #%s created', $_shipment->getIncrementId()), $_shipment->getEmailSent(), $_shipment->getCreatedAtDate());
         foreach ($_shipment->getCommentsCollection() as $_comment) {
             $history[$_comment->getEntityId()] = $this->_prepareHistoryItem($this->__('Shipment #%s comment added', $_shipment->getIncrementId()), $_comment->getIsCustomerNotified(), $_comment->getCreatedAtDate(), $_comment->getComment());
         }
     }
     foreach ($order->getInvoiceCollection() as $_invoice) {
         $history[$_invoice->getEntityId()] = $this->_prepareHistoryItem($this->__('Invoice #%s created', $_invoice->getIncrementId()), $_invoice->getEmailSent(), $_invoice->getCreatedAtDate());
         foreach ($_invoice->getCommentsCollection() as $_comment) {
             $history[$_comment->getEntityId()] = $this->_prepareHistoryItem($this->__('Invoice #%s comment added', $_invoice->getIncrementId()), $_comment->getIsCustomerNotified(), $_comment->getCreatedAtDate(), $_comment->getComment());
         }
     }
     foreach ($order->getTracksCollection() as $_track) {
         $history[$_track->getEntityId()] = $this->_prepareHistoryItem($this->__('Tracking number %s for %s assigned', $_track->getNumber(), $_track->getTitle()), false, $_track->getCreatedAtDate());
     }
     krsort($history);
     return $history;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:36,代码来源:History.php

示例6: events

 public function events()
 {
     $this->document->setTitle("America Travel Info");
     $this->load->model('index/index');
     global $LANGUAGE;
     $this->data['TEXT'] = $LANGUAGE;
     $language = $this->session->data['language'];
     //header banner
     $data = array("language_id" => $language);
     $eventsList = $this->model_index_index->getEvents($data);
     if (!isset($_GET['id'])) {
         $this->data['eventLast'] = $eventsList[0];
     } else {
         if (is_numeric($_GET['id'])) {
             $data['id'] = $_GET['id'];
             $this->data['eventLast'] = $this->model_index_index->getEventOne($data);
         }
     }
     // var_dump($this->data['eventLast']);
     // var_dump($eventsList);
     $result = array();
     foreach ($eventsList as $key => $e) {
         $result[$e['category']][] = $e;
     }
     krsort($result);
     // var_dump($result);
     $this->data['result'] = $result;
     $data['start'] = 0;
     $data['limit'] = 5;
     $events5 = $this->model_index_index->getEvents($data);
     $this->data['events5'] = $events5;
     $this->template = 'index/events.tpl';
     $this->children = array('common/footer', 'common/header');
     $this->response->setOutput($this->render());
 }
开发者ID:howareyoucolin,项目名称:demo,代码行数:35,代码来源:index.php

示例7: listeners

 public function listeners($eventName = null)
 {
     // Return all events in a sorted priority order
     if ($eventName === null) {
         foreach (array_keys($this->listeners) as $eventName) {
             if (empty($this->sorted[$eventName])) {
                 $this->listeners($eventName);
             }
         }
         return $this->sorted;
     }
     // Return the listeners for a specific event, sorted in priority order
     if (empty($this->sorted[$eventName])) {
         $this->sorted[$eventName] = [];
         if (isset($this->listeners[$eventName])) {
             krsort($this->listeners[$eventName], SORT_NUMERIC);
             foreach ($this->listeners[$eventName] as $listeners) {
                 foreach ($listeners as $listener) {
                     $this->sorted[$eventName][] = $listener;
                 }
             }
         }
     }
     return $this->sorted[$eventName];
 }
开发者ID:knedle,项目名称:twitter-nette-skeleton,代码行数:25,代码来源:Emitter.php

示例8: parse_template_bean

 function parse_template_bean($string, $bean_name, &$focus)
 {
     $repl_arr = array();
     foreach ($focus->field_defs as $field_def) {
         if ($field_def['type'] == 'enum' && isset($field_def['options'])) {
             $translated = translate($field_def['options'], $bean_name, $focus->{$field_def}['name']);
             if (isset($translated) && !is_array($translated)) {
                 $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = $translated;
             } else {
                 // unset enum field, make sure we have a match string to replace with ""
                 $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = '';
             }
         } else {
             $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = $focus->{$field_def}['name'];
         }
     }
     // end foreach()
     krsort($repl_arr);
     reset($repl_arr);
     foreach ($repl_arr as $name => $value) {
         if ($value != '' && is_string($value)) {
             $string = str_replace("\${$name}", $value, $string);
         } else {
             $string = str_replace("\${$name}", ' ', $string);
         }
     }
     return $string;
 }
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:28,代码来源:TemplateParser.php

示例9: topEarners

 /**
  * Function will calculate the top publisher results
  * from the performance table
  * @return  Array of Top Earners
  */
 public static function topEarners($users, $dateQuery = [], $count = 10)
 {
     $pubClicks = [];
     $result = [];
     foreach ($users as $u) {
         $perf = \Performance::calculate($u, $dateQuery);
         $clicks = $perf['clicks'];
         if ($clicks === 0) {
             continue;
         }
         if (!array_key_exists($clicks, $pubClicks)) {
             $pubClicks[$clicks] = [];
         }
         $pubClicks[$clicks][] = AM::toObject(['name' => $u->name, 'clicks' => $clicks]);
     }
     if (count($pubClicks) === 0) {
         return $result;
     }
     krsort($pubClicks);
     array_splice($pubClicks, $count);
     $i = 0;
     foreach ($pubClicks as $key => $value) {
         foreach ($value as $u) {
             $result[] = $u;
             $i++;
             if ($i >= $count) {
                 break 2;
             }
         }
     }
     return $result;
 }
开发者ID:vNative,项目名称:vnative,代码行数:37,代码来源:user.php

示例10: siteorigin_custom_css_admin_menu

/**
 * Add the custom CSS editor to the admin menu.
 */
function siteorigin_custom_css_admin_menu()
{
    add_theme_page(__('Custom CSS', 'vantage'), __('Custom CSS', 'vantage'), 'edit_theme_options', 'siteorigin_custom_css', 'siteorigin_custom_css_page');
    if (current_user_can('edit_theme_options') && isset($_POST['siteorigin_custom_css_save'])) {
        check_admin_referer('custom_css', '_sononce');
        $theme = basename(get_template_directory());
        // Sanitize CSS input. Should keep most tags, apart from script and style tags.
        $custom_css = siteorigin_custom_css_clean(filter_input(INPUT_POST, 'custom_css'));
        $current = get_option('siteorigin_custom_css[' . $theme . ']');
        if ($current === false) {
            add_option('siteorigin_custom_css[' . $theme . ']', $custom_css, '', 'no');
        } else {
            update_option('siteorigin_custom_css[' . $theme . ']', $custom_css);
        }
        // If this has changed, then add a revision.
        if ($current != $custom_css) {
            $revisions = get_option('siteorigin_custom_css_revisions[' . $theme . ']');
            if (empty($revisions)) {
                add_option('siteorigin_custom_css_revisions[' . $theme . ']', array(), '', 'no');
                $revisions = array();
            }
            $revisions[time()] = $custom_css;
            // Sort the revisions and cut off any old ones.
            krsort($revisions);
            $revisions = array_slice($revisions, 0, 15, true);
            update_option('siteorigin_custom_css_revisions[' . $theme . ']', $revisions);
        }
    }
}
开发者ID:gipix,项目名称:azm,代码行数:32,代码来源:css.php

示例11: _tidyBrand

 /**
  * 整理品牌
  * 所有品牌全部显示在一级类目下,不显示二三级类目
  * @param array $brand_c_list
  * @return array
  */
 private function _tidyBrand($brand_c_list)
 {
     $brand_listnew = array();
     $brand_class = array();
     $brand_r_list = array();
     if (!empty($brand_c_list) && is_array($brand_c_list)) {
         $goods_class = Model('goods_class')->getGoodsClassForCacheModel();
         foreach ($brand_c_list as $key => $brand_c) {
             $gc_array = $this->_getTopClass($goods_class, $brand_c['class_id']);
             if (empty($gc_array)) {
                 if ($brand_c['show_type'] == 1) {
                     $brand_listnew[0]['text'][] = $brand_c;
                 } else {
                     $brand_listnew[0]['image'][] = $brand_c;
                 }
                 $brand_class[0]['brand_class'] = '其他';
             } else {
                 if ($brand_c['show_type'] == 1) {
                     $brand_listnew[$gc_array['gc_id']]['text'][] = $brand_c;
                 } else {
                     $brand_listnew[$gc_array['gc_id']]['image'][] = $brand_c;
                 }
                 $brand_class[$gc_array['gc_id']]['brand_class'] = $gc_array['gc_name'];
             }
             //推荐品牌
             if ($brand_c['brand_recommend'] == 1) {
                 $brand_r_list[] = $brand_c;
             }
         }
     }
     krsort($brand_class);
     krsort($brand_listnew);
     return array('brand_listnew' => $brand_listnew, 'brand_class' => $brand_class, 'brand_r_list' => $brand_r_list);
 }
开发者ID:mengtaolin,项目名称:shopping,代码行数:40,代码来源:brand.php

示例12: orderTags

 public function orderTags(&$tags, $order)
 {
     switch ($order) {
         case 'alpha':
             usort($tags, create_function('$a, $b', 'return strcmp($a->name, $b->name);'));
             break;
         case 'ralpha':
             usort($tags, create_function('$a, $b', 'return strcmp($b->name, $a->name);'));
             break;
         case 'acount':
             krsort($tags);
             $tags = array_merge($tags);
             break;
         case 'ocount':
             $this->_count_sort($tags);
             break;
         case 'icount':
             krsort($tags);
             $this->_count_sort($tags);
             break;
         case 'random':
             shuffle($tags);
             break;
     }
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:25,代码来源:helper.php

示例13: getPhrases

 public static function getPhrases()
 {
     static $phrases;
     if (!$phrases) {
         $filename = dirname(__FILE__) . '/Data/phrases.cnf';
         if (!file_exists($filename)) {
             throw new Exception("Missing file '{$file}'.");
         }
         $data = file_get_contents($filename);
         // remove comments and empty lines
         $data = preg_replace('/^#(.*)$/m', '', $data);
         $data = preg_replace('/^\\s*\\n/m', '', $data);
         $data = trim($data);
         $data = preg_split('/^\\[([0-9.]+)\\](?:\\s*([0-9+-]+))$/m', $data, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
         //var_dump($data); exit;
         $phrases = array();
         for ($i = 0; $i < count($data); $i += 3) {
             $code = $data[$i];
             $sort = (double) $data[$i + 1];
             $rows = explode("\n", trim($data[$i + 2]));
             if (!isset($phrases[$sort])) {
                 $phrases[$sort] = array();
             }
             $phrases[$sort][$code] = $rows;
         }
         krsort($phrases, SORT_NUMERIC);
         //var_dump($phrases); exit;
     }
     return $phrases;
 }
开发者ID:jsiefer,项目名称:emarketing,代码行数:30,代码来源:Failure.php

示例14: add

 /**
  * Add a route to the collection.
  *
  * @param \Cake\Routing\Route\Route $route The route object to add.
  * @param array $options Additional options for the route. Primarily for the
  *   `_name` option, which enables named routes.
  * @return void
  */
 public function add(Route $route, array $options = [])
 {
     $this->_routes[] = $route;
     // Explicit names
     if (isset($options['_name'])) {
         $this->_named[$options['_name']] = $route;
     }
     // Generated names.
     $name = $route->getName();
     if (!isset($this->_routeTable[$name])) {
         $this->_routeTable[$name] = [];
     }
     $this->_routeTable[$name][] = $route;
     // Index path prefixes (for parsing)
     $path = $route->staticPath();
     if (empty($this->_paths[$path])) {
         $this->_paths[$path] = [];
         krsort($this->_paths);
     }
     $this->_paths[$path][] = $route;
     $extensions = $route->extensions();
     if ($extensions) {
         $this->extensions($extensions);
     }
 }
开发者ID:CakeDC,项目名称:cakephp,代码行数:33,代码来源:RouteCollection.php

示例15: sign

 /**
  * 签名生成
  * @var string
  */
 public static function sign($data = array(), $key, $exchange_rule = "")
 {
     $sign = "";
     if (!empty($exchange_rule)) {
         //加密使用
         $encryptArr = array();
         $encryptArr['~partner_order~'] = $data['partner_order'];
         $encryptArr['~username~'] = $data['username'];
         $encryptArr['~AppId~'] = $data['AppId'];
         $encryptArr['~ServerId~'] = $data['ServerId'];
         $encryptArr['~amount~'] = $data['amount'];
         $search = array_keys($encryptArr);
         $replace = array_values($encryptArr);
         $sign = str_replace($search, $replace, $exchange_rule);
     } else {
         if (!empty($data['sign'])) {
             unset($data['sign']);
         }
         krsort($data);
         foreach ($data as $k => $v) {
             $sign .= $v;
         }
     }
     return md5($sign . $key);
 }
开发者ID:032404cxd,项目名称:prototype_main,代码行数:29,代码来源:String.php


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