當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Arr::sort方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Arr::sort方法的典型用法代碼示例。如果您正苦於以下問題:PHP Arr::sort方法的具體用法?PHP Arr::sort怎麽用?PHP Arr::sort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Arr的用法示例。


在下文中一共展示了Arr::sort方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRoutes

 /**
  * Compile the routes into a displayable format.
  *
  * @return array
  */
 protected function getRoutes()
 {
     $results = [];
     foreach ($this->routes as $route) {
         $results[] = $this->getRouteInformation(collect($route));
     }
     if ($sort = $this->option('sort')) {
         $results = Arr::sort($results, function ($value) use($sort) {
             return $value[$sort];
         });
     }
     if ($this->option('reverse')) {
         $results = array_reverse($results);
     }
     return array_filter($results);
 }
開發者ID:mlntn,項目名稱:lumen-artisan-route-list,代碼行數:21,代碼來源:RouteList.php

示例2: toArray

 static function toArray()
 {
     $ret = [];
     foreach (static::$groups as $name => $group) {
         if (!isset(static::$groups_priority[$name])) {
             static::$groups_priority[$name] = 0;
         }
     }
     static::$groups_priority = Arr::sort(static::$groups_priority, function ($v) {
         return -$v;
     });
     foreach (static::$groups_priority as $name => $p) {
         $group = Arr::get(static::$groups, $name);
         $ret[$name] = $group->toArray();
     }
     return $ret;
 }
開發者ID:larakit,項目名稱:lk,代碼行數:17,代碼來源:WidgetSidebarMenu.php

示例3: getRoutes

 /**
  * Compile the routes into a displayable format.
  *
  * @return array
  */
 protected function getRoutes()
 {
     $routes = [];
     foreach ($this->routes as $collection) {
         foreach ($collection->getRoutes() as $route) {
             $routes[] = $this->filterRoute(['host' => $route->domain(), 'uri' => implode('|', $route->methods()) . ' ' . $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'protected' => $this->routeHasAuthMiddleware($route) ? 'Yes' : 'No', 'versions' => implode(', ', $route->versions()), 'scopes' => implode(', ', $route->scopes())]);
         }
     }
     if ($sort = $this->option('sort')) {
         $routes = Arr::sort($routes, function ($value) use($sort) {
             return $value[$sort];
         });
     }
     if ($this->option('reverse')) {
         $routes = array_reverse($routes);
     }
     return array_filter(array_unique($routes, SORT_REGULAR));
 }
開發者ID:lengdelong,項目名稱:api,代碼行數:23,代碼來源:Routes.php

示例4: getRoutes

 /**
  * Compile the routes into a displayable format.
  *
  * @return array
  */
 protected function getRoutes()
 {
     $routes = [];
     foreach ($this->router->getRoutes() as $collection) {
         foreach ($collection->getRoutes() as $route) {
             $routes[] = $this->filterRoute(['host' => $route->domain(), 'method' => implode('|', $route->methods()), 'uri' => $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'protected' => $route->isProtected() ? 'Yes' : 'No', 'versions' => implode(', ', $route->versions()), 'scopes' => implode(', ', $route->scopes()), 'rate' => $this->routeRateLimit($route)]);
         }
     }
     if ($sort = $this->option('sort')) {
         $routes = Arr::sort($routes, function ($value) use($sort) {
             return $value[$sort];
         });
     }
     if ($this->option('reverse')) {
         $routes = array_reverse($routes);
     }
     if ($this->option('short')) {
         $this->headers = ['Method', 'URI', 'Name', 'Version(s)'];
         $routes = array_map(function ($item) {
             return array_only($item, ['method', 'uri', 'name', 'versions']);
         }, $routes);
     }
     return array_filter(array_unique($routes, SORT_REGULAR));
 }
開發者ID:dingo,項目名稱:api,代碼行數:29,代碼來源:Routes.php

示例5:

 /**
  * Sort the array using the given callback.
  *
  * @param  array $array
  * @param  callable $callback
  * @return array
  */
 function array_sort($array, callable $callback)
 {
     return Arr::sort($array, $callback);
 }
開發者ID:saj696,項目名稱:pipe,代碼行數:11,代碼來源:helpers.php

示例6:

 /**
  * Sort the array using the given Closure.
  *
  * @param  array     $array
  * @param  \Closure  $callback
  * @return array
  */
 function array_sort($array, Closure $callback)
 {
     return Arr::sort($array, $callback);
 }
開發者ID:bhoopal10,項目名稱:PayrollOriginal,代碼行數:11,代碼來源:helpers.php


注:本文中的Illuminate\Support\Arr::sort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。