本文整理匯總了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);
}