当前位置: 首页>>代码示例>>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;未经允许,请勿转载。