本文整理汇总了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);
}
示例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;
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}