本文整理汇总了PHP中array_sort函数的典型用法代码示例。如果您正苦于以下问题:PHP array_sort函数的具体用法?PHP array_sort怎么用?PHP array_sort使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_sort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*/
public function fire()
{
$tableBuilder = $this->getHelperSet()->get('table');
// Build summary
$table = [];
$this->getQueries();
foreach ($this->queries as $route => $log) {
$table[$route] = [$route, count($log['queries'])];
}
// Sort by number of queries
$table = array_sort($table, function ($entry) {
return $entry[1] * -1;
});
// Filter out low-query pages
$table = array_filter($table, function ($entry) {
return $entry[1] > 10;
});
// Render
$tableBuilder->setHeaders(['Route', 'Queries'])->setRows($table);
$tableBuilder->render($this->getOutput());
if ($route = $this->option('route')) {
$route = $this->laravel['url']->to($route);
echo $this->queries[$route]['response'];
print_r($this->queries[$route]['queries']);
}
}
示例2: getStatusArray
public static function getStatusArray() {
$db = XenForo_Application::get('db');
$userModel = new Xenforo_Model_User;
$options = XenForo_Application::get('options');
$numStatusShown = $options->RCBDRecentStatusNumView;
$showComments = $options->RCBDRecentStatusShowComments;
$onePerUser = $options->RCBDRecentStatusOnePerUser;
$data = XenForo_Application::getSimpleCacheData("RCBDRecentStatus_status_array");
if (!$data) {
if ($onePerUser == 1) {
$statusArray = $db->fetchAll($db->limit("SELECT * FROM (SELECT * FROM xf_profile_post WHERE message_state <> 'deleted' AND profile_user_id = user_id ORDER BY post_date DESC) t1 GROUP BY t1.user_id ORDER BY post_date DESC", $numStatusShown));
$statusArray = array_sort($statusArray, "post_date");
} else {
$statusArray = $db->fetchAll($db->limit("SELECT * FROM xf_profile_post WHERE profile_user_id = user_id AND message_state <> 'deleted' ORDER BY post_date DESC", $numStatusShown));
}
XenForo_Application::setSimpleCacheData("RCBDRecentStatus_status_array", $statusArray);
} else {
$statusArray = $data;
}
$recentStatus = array();
$postIds = array();
if (sizeof($statusArray) == 0) {
$statusArray = array(0 => array("profile_post_id" => 0, "user_id" => 1, "post_date" => time(), "message" => "No status entries yet, be the first!"));
}
foreach ($statusArray as $status) {
$postIds[] = $status['profile_post_id'];
}
$commentsArray = array();
$commentsSortedArray = array();
if ($showComments == 1) {
$matches = implode(',', $postIds);
$data = XenForo_Application::getSimpleCacheData("RCBDRecentStatus_comments_array");
if (!$data) {
$commentsArray = $db->fetchAll($db->limit("SELECT * FROM xf_profile_post_comment WHERE profile_post_id in(" . $matches . ") ORDER BY profile_post_id DESC, comment_date", $numStatusShown));
XenForo_Application::setSimpleCacheData("RCBDRecentStatus_comments_array", $commentsArray);
} else {
$commentsArray = $data;
}
$commentsUserObjs = getUserData($commentsArray);
$currentPostId = -99;
$commentGroup = array();
foreach ($commentsArray as $status) {
if ($currentPostId != $status['profile_post_id']) {
if ($currentPostId != -99) {
$commentsSortedArray[$currentPostId] = $commentGroup;
$commentGroup = array();
}
$currentPostId = $status['profile_post_id'];
}
$commentGroup[] = array("user" => $commentsUserObjs[$status['user_id']], "status" => $status['message'], "time" => $status['comment_date'], "post_id" => $status['profile_post_id']);
}
$commentsSortedArray[$currentPostId] = $commentGroup;
}
$statusUserObjs = getUserData($statusArray);
foreach ($statusArray as $status) {
$recentStatus[] = array("user" => $statusUserObjs[$status['user_id']], "status" => $status['message'], "time" => $status['post_date'], "post_id" => $status['profile_post_id']);
}
$returnArrays = array("status" => $recentStatus, "comments" => $commentsSortedArray);
return $returnArrays;
}
示例3: prod__list
function prod__list()
{
$out = aikiGetForm($_GET["form"], $_GET["mode"]);
$flag = "";
$where = "";
if (isset($_GET["division"]) && $_GET["division"] > "") {
$where = aikiWhereFromTree("prod_division", $_GET["division"], "division");
$flag = "division";
}
$Item = aikiListItems($_GET["form"], $where);
$Item["result"] = array_sort($Item["result"], "id");
$Item["form"] = $_GET["form"];
$out->contentSetData($Item);
$out->contentSetValues($Item);
$modal = $out->find("div.modal");
foreach ($modal as $m) {
if ($m->attr("id") == "") {
$m->attr("id", "{$_GET["form"]}Edit");
}
$m->attr("data-backdrop", "static");
if ($m->find("[data-formsave]")->length && $m->find("[data-formsave]")->attr("data-formsave") == "") {
$m->find("[data-formsave]")->attr("data-formsave", "#{$_GET["form"]}EditForm");
}
if ($m->find(".modal-title")->html() == "") {
$m->find(".modal-title")->html("Редактирование");
}
}
if ($flag == "division") {
$out = $out->find("#prodList .list")->html();
return $out;
}
if ($flag == "") {
return $out->outerHtml();
}
}
示例4: __construct
public function __construct(Player $player, array $properties, array $stats = null)
{
parent::__construct($properties);
$this->player = $player;
$this->statistics = new AccountStatistics($this, $stats);
$properties['characters'] = array_sort($properties['characters'], function ($value) {
return $value['characterBase']['characterId'];
});
$this->characters = new CharacterCollection($this, $properties['characters']);
}
示例5: sortSections
private function sortSections($sections)
{
$sorts = ['F' => 1, 'W' => 2, 'Sp' => 3, 'Su' => 4];
return array_sort($sections, function ($section) use($sorts) {
$term = array_get($section, 'term');
$year = substr($term, -2);
$quarter = substr($term, 0, strlen($term) - 2);
return [$year, array_get($sorts, $quarter), array_get($section, 'section_number')];
});
}
示例6: sql_loadTransCats
function sql_loadTransCats($myc, $uvjet)
{
global $dconf, $debug;
$chdb = sql_readtable($myc, 'trans_cat', $uvjet);
if (!$chdb) {
return false;
}
array_sort($chdb, "type");
return $chdb;
}
示例7: str_bind
/**
* Bind a associative array values to equivalent on string with colons.
* @param string $str
* @param array $replace
* @example str_bind("Hello :name!", ["name" => "World"]) // "Hello World!"
* @return mixed
*/
function str_bind($str, $replace = [])
{
$replace = array_sort($replace, function ($value, $key) {
return mb_strlen($key) * -1;
});
foreach ($replace as $key => $value) {
$str = str_replace(':' . $key, $value, $str);
}
return $str;
}
示例8: sort
public function sort($sortColumn)
{
if ($this->has($sortColumn)) {
$this->data = array_sort($this->get($sortColumn, []), function ($value, $key) {
return $key;
});
$this->persist();
}
return $this;
}
示例9: getMenu
function getMenu($listMenus)
{
global $langage;
//Filtrage entre les différents menus
$parentsMenus = array();
$linksMenus = array();
//Classification des menus
foreach ($listMenus as $menu) {
if ($menu->id_parent_menu == NULL) {
$parentsMenus[] = $menu;
} else {
$linksMenus[] = $menu;
}
}
//effectuer un tri des menus
$PM_Tri = array_sort($parentsMenus, SORT_COLUMN_NAME);
$LM_Tri = array_sort($linksMenus, SORT_COLUMN_NAME);
$HTMLMenu = "";
//Traitement des menus
foreach ($PM_Tri as $parentMenu) {
if ($parentMenu->type_url == Menu::TYPE_URL_AJAX || $parentMenu->type_url == Menu::TYPE_URL_EXTERNE) {
switch ($parentMenu->type_url) {
case Menu::TYPE_URL_AJAX:
$template = TEMPLATE_AJAX;
break;
case Menu::TYPE_URL_EXTERNE:
$template = TEMPLATE_SIMPLE_URL;
break;
default:
break;
}
$HTMLMenu .= buildUrlMenu($parentMenu, null, $template);
} else {
$navbar_menu_links = "";
foreach ($LM_Tri as $linkmenu) {
if ($linkmenu->id_parent_menu == $parentMenu->id_menu) {
switch ($linkmenu->type_url) {
case Menu::TYPE_URL_AJAX:
$template = TEMPLATE_AJAX;
break;
case Menu::TYPE_URL_EXTERNE:
$template = TEMPLATE_SIMPLE_URL;
break;
default:
break;
}
$navbar_menu_links .= buildUrlMenu($linkmenu, null, $template);
}
}
$HTMLMenu .= buildUrlMenu($parentMenu, $navbar_menu_links, TEMPLATE_PARENT_MENU);
}
}
return $HTMLMenu;
}
示例10: parseFacet
public function parseFacet($root, $name)
{
$values = [];
foreach ($root->xpath('//s:FACET[@NAME="' . $name . '"]/s:FACET_VALUES') as $value) {
$values[] = ['value' => $value->attr('KEY'), 'count' => intval($value->attr('VALUE'))];
}
$values = array_reverse(array_sort($values, function ($value) {
return $value['count'];
}));
return array_slice($values, 0, 10);
}
示例11: page__list
function page__list()
{
$out = aikiGetForm($_GET["form"], $_GET["mode"]);
$Item = aikiListItems("page");
$Item["result"] = array_sort($Item["result"], "id");
$out->contentSetData($Item);
$out->find("div.modal")->attr("id", "pageEdit");
$out->find("div.modal")->attr("data-backdrop", "static");
$out->find("[data-formsave]")->attr("data-formsave", "#pageEditForm");
$out->find(".modal-title")->html("Редактирование страницы");
return $out->outerHtml();
}
示例12: dict__list
function dict__list()
{
$form = $_GET["form"];
$out = aikifromFile("http://{$_SERVER["HTTP_HOST"]}/engine/forms/{$form}/{$form}_list.php");
$Item = aikiListItems("comments");
$Item["result"] = array_sort($Item["result"], "date", SORT_DESC);
$out->contentSetData($Item);
$out->find("div.modal")->attr("id", "{$form}Edit");
$out->find("div.modal")->attr("data-backdrop", "static");
$out->find("[data-formsave]")->attr("data-formsave", "#{$form}EditForm");
$out->find(".modal-title")->html("Редактирование справочника");
return $out->outerHtml();
}
示例13: nation_phone_array
/**
* Create the nation phone list array, include nation name & phone code
* Format like [nation_name][_][phone_code]. Ex: Australlia +61
*/
function nation_phone_array()
{
$option = "";
$contents = file_get_contents(realpath(public_path('json/countries.json')));
$countries = json_decode(stripslashes($contents), true);
$countries = array_values(array_sort($countries, function ($value) {
return $value['name'];
}));
$nationPhones = array_map(function ($country) {
return $country['name'] . ' ' . $country['phone'];
}, $countries);
return $nationPhones;
}
示例14: getTableState
protected function getTableState()
{
$table = [];
$config = $this->config['state'];
foreach ($this->states as $state) {
if (in_array($state, array_keys($config))) {
$table[] = $config[$state];
}
}
$table = array_sort($table, function ($value) {
return $value['position'];
});
return $table;
}
示例15: syncdata
public function syncdata(Request $request)
{
/*$client = new Client([
// Base URI is used with relative requests
'base_uri' => 'https://todoist.com',
// You can set any number of default request options.
'timeout' => 2.0,
]);
$response = $client->request('POST', '/oauth/access_token', [
"form_params" => [
"client_id"=>"de27417420bf4d14881b239ed8506e1d" ,
"client_secret"=>"dce0445f47794e51ad85b70090524cb9" ,
"code"=> $request->input('code')
]
]);
$token = json_decode($response->getBody()->getContents())->access_token;
var_dump($token);*/
$client = new Client();
$response = $client->request('POST', 'https://todoist.com/API/v6/sync', ["form_params" => ["token" => "31ecf41c4338d45dd4c6ad65f706207366691925", "seq_no" => uniqid(), "resource_types" => '["all"]']]);
$data = json_decode($response->getBody()->getContents());
$projects = array_values(array_sort($data->Projects, function ($value) {
$value = (array) $value;
return $value['item_order'];
}));
DB::table('project_user')->delete();
DB::table('label_todo')->delete();
DB::table('todos')->where("estimated_time", 0)->delete();
$todos = $data->Items;
$labels = $data->Labels;
$user = $data->User;
$collaborators = $data->Collaborators;
$collaboratorStates = $data->CollaboratorStates;
//var_dump($todos);
$this->user = $user;
$this->collaborators = $collaborators;
$this->projects = $projects;
$this->collaboratorStates = $collaboratorStates;
$this->todos = $todos;
$this->labels = $labels;
$this->updateLabels();
$this->updateUser();
$this->updateConnectedUsers();
$this->updateProjectList();
$this->updateCollaboratorStates();
$this->updateTodoList();
return Redirect::back();
}