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


PHP array_multisort函数代码示例

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


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

示例1: liste_matchs_semaine

 public function liste_matchs_semaine($groupe)
 {
     // On liste les équipes du groupe
     $query = "SELECT * FROM projet.equipe WHERE id_groupe=? ORDER BY nom";
     $equipes = $this->db->query($query, array($groupe));
     $equipes = $equipes->result_array();
     // $date_day_moins_semaine = new DateTime('last monday');
     // $date_day = new DateTime('next monday');
     $date_day_moins_semaine = new DateTime('2015-11-30 last monday');
     $date_day = new DateTime('2015-11-30 next monday');
     // Array qui contiendra tout les matchs du jour
     $matchs_semaine = array();
     // On liste tout les matchs du jour
     foreach ($equipes as $key => $equipe) {
         $matchs = $this->liste_matchs($equipe['id_equipe']);
         // on récupère tout les matchs de l'équipe
         $nb_match = sizeof($matchs);
         // On vois le nombre de match sortie
         foreach ($matchs as $match) {
             if ($match['date'] >= $date_day_moins_semaine->format('Y-m-d') and $match['date'] <= $date_day->format('Y-m-d')) {
                 // On vérifie que les matchs dates de moins de 1 semaine
                 $matchs_semaine[$match['id_match']] = $match;
             }
         }
     }
     // Trie du tableau en fonction de la date des matchs
     foreach ($matchs_semaine as $key => $value) {
         $lm[$key] = $value['date'];
     }
     if (!empty($matchs_semaine)) {
         array_multisort($lm, SORT_DESC, $matchs_semaine);
     }
     return $matchs_semaine;
 }
开发者ID:PtitZef,项目名称:Projet2A,代码行数:34,代码来源:groupeModel.php

示例2: getHTMLFormatted

 /**
  * Default HTML formatting implementation for error messages
  * @param $config Configuration array, vital for HTML output nature
  */
 function getHTMLFormatted($config)
 {
     $ret = array();
     $errors = $this->errors;
     // sort error array by line
     // line numbers are enabled if they aren't explicitly disabled
     if ($config->get('Core', 'MaintainLineNumbers') !== false) {
         $has_line = array();
         $lines = array();
         $original_order = array();
         foreach ($errors as $i => $error) {
             $has_line[] = (int) (bool) $error[0];
             $lines[] = $error[0];
             $original_order[] = $i;
         }
         array_multisort($has_line, SORT_DESC, $lines, SORT_ASC, $original_order, SORT_ASC, $errors);
     }
     foreach ($errors as $error) {
         list($line, $severity, $msg) = $error;
         $string = '';
         $string .= '<strong>' . $this->locale->getErrorName($severity) . '</strong>: ';
         $string .= $this->generator->escape($msg);
         if ($line) {
             // have javascript link generation that causes
             // textarea to skip to the specified line
             $string .= $this->locale->formatMessage('ErrorCollector: At line', array('line' => $line));
         }
         $ret[] = $string;
     }
     if (empty($errors)) {
         return '<p>' . $this->locale->getMessage('ErrorCollector: No errors') . '</p>';
     } else {
         return '<ul><li>' . implode('</li><li>', $ret) . '</li></ul>';
     }
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:39,代码来源:ErrorCollector.php

示例3: sortBySubkey

function sortBySubkey(&$array, $subkey, $sortType = SORT_DESC)
{
    foreach ($array as $subarray) {
        $keys[] = $subarray[$subkey];
    }
    array_multisort($keys, $sortType, $array);
}
开发者ID:samtechnocrat,项目名称:ClinicCases,代码行数:7,代码来源:rss.php

示例4: getMethod

 public function getMethod($country_id = '', $zone_id = '', $postcode = '')
 {
     $this->load->language('payment/free_checkout');
     $method_data = array();
     $status = FALSE;
     if ($this->config->get('free_checkout_status')) {
         $method_data = array();
         // Get All taxes, shipping fees, and order totals to be sure the price is still 0.00
         $total = 0;
         $taxes = $this->cart->getTaxes();
         $this->load->model('checkout/extension');
         $sort_order = array();
         $results = $this->model_checkout_extension->getExtensions('total');
         foreach ($results as $key => $value) {
             $sort_order[$key] = $this->config->get($value['key'] . '_sort_order');
         }
         array_multisort($sort_order, SORT_ASC, $results);
         foreach ($results as $result) {
             $this->load->model('total/' . $result['key']);
             $this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
         }
         if ($total <= 0) {
             $status = TRUE;
         }
         if ($status) {
             $method_data = array('id' => 'free_checkout', 'title' => $this->language->get('text_title'), 'sort_order' => $this->config->get('free_checkout_sort_order'));
         }
     }
     return $method_data;
 }
开发者ID:josueaponte7,项目名称:necotienda_standalone,代码行数:30,代码来源:free_checkout.php

示例5: form_membership_level

 public function form_membership_level($id)
 {
     ob_start();
     $id = $_POST['id'];
     $wpm_levels = $this->wlm->GetOption('wpm_levels');
     $level = $wpm_levels[$id];
     $pages = get_pages('exclude=' . implode(',', $this->wlm->ExcludePages(array(), true)));
     $pages_options = '';
     foreach ((array) $pages as $page) {
         $pages_options .= '<option value="' . $page->ID . '">' . $page->post_title . '</option>';
     }
     $roles = $GLOBALS['wp_roles']->roles;
     $caps = array();
     foreach ((array) $roles as $key => $role) {
         if ($role['capabilities']['level_10'] || $role['capabilities']['level_9'] || $role['capabilities']['level_8']) {
             unset($roles[$key]);
         } else {
             list($roles[$key]) = explode('|', $role['name']);
             $caps[$key] = count($role['capabilities']);
         }
     }
     array_multisort($caps, SORT_ASC, $roles);
     include $this->wlm->pluginDir . '/resources/forms/edit_membership_level.php';
     $str = ob_get_clean();
     echo $str;
     //return $str;
     die;
 }
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:28,代码来源:WishListXhr.php

示例6: getList

 public static function getList($siteId, $arFilter = array(), $arOrder = array())
 {
     if (empty($siteId)) {
         throw new ArgumentNullException("siteId");
     }
     $arUrlRewrite = static::loadRules($siteId);
     $arResult = array();
     $arResultKeys = self::filterRules($arUrlRewrite, $arFilter);
     foreach ($arResultKeys as $key) {
         $arResult[] = $arUrlRewrite[$key];
     }
     if (!empty($arOrder) && !empty($arResult)) {
         $arOrderKeys = array_keys($arOrder);
         $orderBy = array_shift($arOrderKeys);
         $orderDir = $arOrder[$orderBy];
         $orderBy = strtoupper($orderBy);
         $orderDir = strtoupper($orderDir);
         $orderDir = $orderDir == "DESC" ? SORT_DESC : SORT_ASC;
         $ar = array();
         foreach ($arResult as $key => $row) {
             $ar[$key] = $row[$orderBy];
         }
         array_multisort($ar, $orderDir, $arResult);
     }
     return $arResult;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:26,代码来源:urlrewriter.php

示例7: actionGeneralSettings

 /**
  * Shows the general settings form.
  *
  * @param array $variables
  */
 public function actionGeneralSettings(array $variables = array())
 {
     if (empty($variables['info'])) {
         $variables['info'] = Craft::getInfo();
     }
     // Assemble the timezone options array
     // (Technique adapted from http://stackoverflow.com/a/7022536/1688568)
     $variables['timezoneOptions'] = array();
     $utc = new DateTime();
     $offsets = array();
     $timezoneIds = array();
     $includedAbbrs = array();
     foreach (\DateTimeZone::listIdentifiers() as $timezoneId) {
         $timezone = new \DateTimeZone($timezoneId);
         $transition = $timezone->getTransitions($utc->getTimestamp(), $utc->getTimestamp());
         $abbr = $transition[0]['abbr'];
         $offset = round($timezone->getOffset($utc) / 60);
         if ($offset) {
             $hour = floor($offset / 60);
             $minutes = floor(abs($offset) % 60);
             $format = sprintf('%+d', $hour);
             if ($minutes) {
                 $format .= ':' . sprintf('%02u', $minutes);
             }
         } else {
             $format = '';
         }
         $offsets[] = $offset;
         $timezoneIds[] = $timezoneId;
         $includedAbbrs[] = $abbr;
         $variables['timezoneOptions'][$timezoneId] = 'UTC' . $format . ($abbr != 'UTC' ? " ({$abbr})" : '') . ($timezoneId != 'UTC' ? ' - ' . $timezoneId : '');
     }
     array_multisort($offsets, $timezoneIds, $variables['timezoneOptions']);
     $this->renderTemplate('settings/general/index', $variables);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:40,代码来源:SystemSettingsController.php

示例8: searchNGram

 public static function searchNGram($cuv)
 {
     $leng = mb_strlen($cuv);
     $hash = NGram::searchLexemIds($cuv);
     if (empty($hash)) {
         return array();
     }
     arsort($hash);
     $max = current($hash);
     $lexIds = array_keys($hash, $max);
     $results = array();
     foreach ($lexIds as $id) {
         $lexem = Model::factory('Lexem')->where('id', $id)->where_gte('charLength', $leng - self::$LENGTH_DIF)->where_lte('charLength', $leng + self::$LENGTH_DIF)->find_one();
         if ($lexem) {
             $results[] = $lexem;
             if (count($results) == self::$MAX_RESULTS) {
                 break;
             }
         }
     }
     // Sort the lexems by their Levenshtein distance from $cuv
     $distances = array();
     foreach ($results as $lexem) {
         $distances[] = Levenshtein::dist($cuv, $lexem->formNoAccent);
     }
     array_multisort($distances, $results);
     return $results;
 }
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:28,代码来源:NGram.php

示例9: parseWeights

 /**
  * Parses an HTTP header into a weight map, that is an associative array
  * mapping values to their respective weights. Any header name preceding
  * weight spec is ignored for convenience.
  *
  * This implementation is partially based on the code at
  * http://www.thefutureoftheweb.com/blog/use-accept-language-header
  *
  * Note that type parameters and accept extension like the "level" parameter
  * are not supported, weights are derived from "q" values only.
  *
  * @todo: If additional type parameters are present, ignore them cleanly.
  *        At present, they often confuse the result.
  *
  * See HTTP/1.1 section 14 for details.
  *
  * @param string $rawHeader
  *
  * @return array
  */
 public function parseWeights($rawHeader)
 {
     //FIXME: The code below was copied and adapted from WebRequest::getAcceptLang.
     //       Move this utility class into core for reuse!
     // first, strip header name
     $rawHeader = preg_replace('/^[-\\w]+:\\s*/', '', $rawHeader);
     // Return values in lower case
     $rawHeader = strtolower($rawHeader);
     // Break up string into pieces (values and q factors)
     $value_parse = null;
     preg_match_all('@([a-z\\d*]+([-+/.][a-z\\d*]+)*)\\s*(;\\s*q\\s*=\\s*(1(\\.0{0,3})?|0(\\.\\d{0,3})?)?)?@', $rawHeader, $value_parse);
     if (!count($value_parse[1])) {
         return array();
     }
     $values = $value_parse[1];
     $qvalues = $value_parse[4];
     $indices = range(0, count($value_parse[1]) - 1);
     // Set default q factor to 1
     foreach ($indices as $index) {
         if ($qvalues[$index] === '') {
             $qvalues[$index] = 1;
         } elseif ($qvalues[$index] == 0) {
             unset($values[$index], $qvalues[$index], $indices[$index]);
         } else {
             $qvalues[$index] = (double) $qvalues[$index];
         }
     }
     // Sort list. First by $qvalues, then by order. Reorder $values the same way
     array_multisort($qvalues, SORT_DESC, SORT_NUMERIC, $indices, $values);
     // Create a list like "en" => 0.8
     $weights = array_combine($values, $qvalues);
     return $weights;
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:53,代码来源:HttpAcceptParser.php

示例10: getFields

 /**
  * {@inheritdoc}
  */
 protected function getFields(DatagridConfiguration $config)
 {
     $entityClassName = $this->entityClassResolver->getEntityClass($this->getEntityName($config));
     if (!$this->configManager->hasConfig($entityClassName)) {
         return [];
     }
     $entityConfigProvider = $this->configManager->getProvider('entity');
     $extendConfigProvider = $this->configManager->getProvider('extend');
     $viewConfigProvider = $this->configManager->getProvider('view');
     $datagridConfigProvider = $this->configManager->getProvider('datagrid');
     $fields = [];
     $priorities = [];
     $fieldIds = $entityConfigProvider->getIds($entityClassName);
     /** @var FieldConfigId $fieldId */
     foreach ($fieldIds as $fieldId) {
         $extendConfig = $extendConfigProvider->getConfigById($fieldId);
         if ($extendConfig->is('owner', ExtendScope::OWNER_CUSTOM) && $datagridConfigProvider->getConfigById($fieldId)->is('is_visible') && !$extendConfig->is('state', ExtendScope::STATE_NEW) && !$extendConfig->is('is_deleted')) {
             $fields[] = $fieldId;
             $viewConfig = $viewConfigProvider->getConfig($entityClassName, $fieldId->getFieldName());
             $priorities[] = $viewConfig->get('priority', false, 0);
         }
     }
     array_multisort($priorities, SORT_DESC, $fields);
     return $fields;
 }
开发者ID:northdakota,项目名称:platform,代码行数:28,代码来源:DynamicFieldsExtension.php

示例11: indexAction

 public function indexAction()
 {
     function deepStrlen($data)
     {
         if (is_scalar($data)) {
             return strlen($data);
         } else {
             if (is_array($data)) {
                 $sum = 0;
                 foreach ($data as $k => $v) {
                     $sum += deepStrlen($v);
                 }
                 return $sum;
             } else {
                 if (is_object($data)) {
                     return 0;
                 }
             }
         }
     }
     $profile = array();
     $sets = array();
     $names = array();
     foreach ($this->cache_keys as $k => $key) {
         $profile[$key] = array('set' => $isset = $value = apc_fetch($this->hash . '-' . $key) !== false ? true : false, 'value' => $value, 'size' => $isset ? deepStrlen($value) : 'N/A');
         $sets[$k] = $isset;
         $names[$k] = $key;
     }
     array_multisort($sets, SORT_DESC, $names, SORT_ASC, $profile);
     $this->view->profile = $profile;
 }
开发者ID:jeremykendall,项目名称:spaz-api,代码行数:31,代码来源:CacheController.php

示例12: buildCategories

 function buildCategories($categories, $parentId)
 {
     $childCategories = array();
     $ids = array();
     foreach ($categories as $category) {
         if ($category['Category']['cat_parent_id'] == $parentId) {
             $childCategories[] = $category['Category'];
         }
         $ids[$category['Category']['id']] = $category['Category'];
     }
     $holdParentId = $parentId;
     while ($holdParentId != 0) {
         $parent = array($ids[$holdParentId]);
         $currentId = $parent[0]['id'];
         $holdParentId = $ids[$holdParentId]['cat_parent_id'];
         foreach ($categories as $category) {
             if ($category['Category']['cat_parent_id'] == $holdParentId && !in_array($category['Category'], $parent)) {
                 $parent[] = $category['Category'];
             }
         }
         array_multisort($parent);
         $n = count($parent);
         $childCategories2 = array();
         for ($i = 0; $i < $n; $i++) {
             $childCategories2[] = $parent[$i];
             if ($parent[$i]['id'] == $currentId) {
                 $childCategories2 = array_merge($childCategories2, $childCategories);
             }
         }
         $childCategories = $childCategories2;
     }
     return $childCategories;
 }
开发者ID:johnulist,项目名称:ecommerce,代码行数:33,代码来源:category.php

示例13: sortBooks

 /**
  * Returns books in a particular order
  * @param type $sort_type
  * @param type $order
  * @return type
  */
 public function sortBooks($sort_type, $order)
 {
     // Obtain a list of columns
     foreach ($this->books as $key => $row) {
         $title[$key] = $row['title'];
         $author[$key] = $row['author'];
         $date_added[$key] = $row['date_added'];
     }
     // Sort the data with volume descending, edition ascending
     // Add $data as the last parameter, to sort by the common key
     switch ($sort_type) {
         case Collections::SORT_TYPE_TITLE:
             array_multisort($title, $order == SORT_DESC ? SORT_DESC : SORT_ASC, $author, SORT_ASC, $date_added, SORT_DESC, $this->books);
             break;
         case Collections::SORT_TYPE_AUTHOR:
             array_multisort($author, $order == SORT_DESC ? SORT_DESC : SORT_ASC, $title, SORT_ASC, $date_added, SORT_DESC, $this->books);
             break;
         case Collections::SORT_TYPE_DATE_ADDED:
             array_multisort($date_added, $order == SORT_DESC ? SORT_DESC : SORT_ASC, $title, SORT_ASC, $author, SORT_ASC, $this->books);
             break;
         default:
             throw new Exception("Invalid sort type");
     }
     return $this->books;
 }
开发者ID:Michaeldgeek,项目名称:NacossUnn,代码行数:31,代码来源:Collections.php

示例14: loadFromCart

 public function loadFromCart($c)
 {
     $ids = array();
     $product_data = array();
     if (($cart = Session::get('cart')) != false) {
         foreach ($cart as $v => $qty) {
             array_push($ids, $v);
         }
         $v = Model::load('ProductVariant');
         $id_string = $v->buildUnionString($ids);
         $product_data = $v->getCartData($id_string);
         foreach ($product_data as $index => $value) {
             $id = $value['id'];
             $price = $value['price'];
             $qty = $cart[$id]['qty'];
             $product_data[$index]['qty'] = $qty;
             $product_data[$index]['line'] = $qty * $price;
             $product_data[$index]['stamp'] = $cart[$id]['stamp'];
         }
         // sort
         foreach ($product_data as $key => $row) {
             $stamp[$key] = $row['stamp'];
             unset($row['stamp']);
         }
         array_multisort($stamp, SORT_ASC, $product_data);
     }
     return $product_data;
 }
开发者ID:mikejw,项目名称:elib-experimental,代码行数:28,代码来源:ShoppingCart.php

示例15: getConnectionsModel

 public function getConnectionsModel($id)
 {
     $connid = "";
     $connection = "";
     $inc = "";
     $this->db->select('tbl_messages.id as messageid, tbl_messages.created_on as message_logtime, tbl_messages.message, tbl_ceos.first_name, tbl_ceos.last_name, tbl_ceos.id as msg_ceos_id, tbl_ceos.ceo_profile_pic, tbl_businesses.id as business_id, tbl_businesses.business_name');
     $this->db->from('tbl_messages');
     $this->db->join('tbl_ceos', 'tbl_ceos.id = tbl_messages.ceo2_id AND tbl_messages.ceo2_id != "' . $id . '" OR tbl_ceos.id = tbl_messages.ceo1_id AND tbl_messages.ceo1_id != "' . $id . '" ', 'left');
     $this->db->join('tbl_ceo_business_details', 'tbl_ceo_business_details.ceo_id = tbl_ceos.id', 'left');
     $this->db->join('tbl_businesses', 'tbl_businesses.id = tbl_ceo_business_details.business_id', 'left');
     $this->db->where("(tbl_messages.ceo1_id = '" . $id . "' OR tbl_messages.ceo2_id = '" . $id . "' )");
     $this->db->order_by('tbl_messages.id', 'asc');
     $resultss = $this->db->get();
     if ($resultss->num_rows() > 0) {
         foreach ($resultss->result() as $key => $val) {
             $connection[$val->msg_ceos_id] = $val;
         }
         $sortArray = array();
         foreach ($connection as $person) {
             foreach ($person as $key => $value) {
                 if (!isset($sortArray[$key])) {
                     $sortArray[$key] = array();
                 }
                 $sortArray[$key][] = $value;
             }
         }
         $orderby = "messageid";
         //change this to whatever key you want from the array
         array_multisort($sortArray[$orderby], SORT_DESC, $connection);
     }
     return $connection;
 }
开发者ID:karaningenious,项目名称:rondas,代码行数:32,代码来源:Message_model.php


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