本文整理汇总了PHP中Illuminate\Support\Arr::collapse方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::collapse方法的具体用法?PHP Arr::collapse怎么用?PHP Arr::collapse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Arr
的用法示例。
在下文中一共展示了Arr::collapse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: explode
/**
* Get an item from an array or object using "dot" notation.
*
* @param mixed $target
* @param string|array $key
* @param mixed $default
* @return mixed
*/
function data_get($target, $key, $default = null)
{
if (is_null($key)) {
return $target;
}
$key = is_array($key) ? $key : explode('.', $key);
while (($segment = array_shift($key)) !== null) {
if ($segment === '*') {
if ($target instanceof Collection) {
$target = $target->all();
} elseif (!is_array($target)) {
return value($default);
}
$result = Arr::pluck($target, $key);
return in_array('*', $key) ? Arr::collapse($result) : $result;
}
if (Arr::accessible($target) && Arr::exists($target, $segment)) {
$target = $target[$segment];
} elseif (is_object($target) && isset($target->{$segment})) {
$target = $target->{$segment};
} else {
return value($default);
}
}
return $target;
}
示例2: init
/**
* @return $this
*/
public function init()
{
$config = Arr::collapse([$this->loadIlluminateConfiguration(), $this->loadFiledConfiguration()]);
$this->application->instance('env', 'production');
$this->application->instance('config', new Repository($config));
$this->application->registerConfiguredProviders();
$this->application->singleton(HttpKernelContract::class, HttpKernel::class);
$this->application->singleton(ConsoleKernelContract::class, ConsoleKernel::class);
$this->application->singleton(ExceptionHandler::class, Handler::class);
if ($this->application->isInstalled()) {
$this->application->register(ThemeServiceProvider::class);
$this->application->register(MenuServiceProvider::class);
$this->application->register(CategoryServiceProvider::class);
$this->application->register(ArticleServiceProvider::class);
$this->application->register(HttpServiceProvider::class);
$this->application->register(PageServiceProvider::class);
$this->application->register(AdminServiceProvider::class);
} else {
$this->application->register(InstallServiceProvider::class);
}
return $this;
}
示例3: collapse
/**
* Collapse the collection of items into a single array.
*
* @return static
*/
public function collapse()
{
return new static(Arr::collapse($this->items));
}
示例4:
/**
* Collapse an array of arrays into a single array.
*
* @param array|\ArrayAccess $array
* @return array
*/
function array_collapse($array)
{
return Arr::collapse($array);
}