当前位置: 首页>>代码示例>>PHP>>正文


PHP Arr::exists方法代码示例

本文整理汇总了PHP中Illuminate\Support\Arr::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::exists方法的具体用法?PHP Arr::exists怎么用?PHP Arr::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Arr的用法示例。


在下文中一共展示了Arr::exists方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:sa7bi,项目名称:euro16,代码行数:34,代码来源:helpers.php

示例2: locale

 public function locale($lang, Request $request)
 {
     if (Arr::exists(config('locales'), $lang)) {
         Session::set('locale', $lang);
     }
     if (isset($_SERVER['HTTP_REFERER'])) {
         return redirect('/')->setTargetUrl($_SERVER['HTTP_REFERER'])->withCookie('locale', $lang);
     } else {
         return redirect('/')->withCookie('locale', $lang);
     }
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:11,代码来源:HomeController.php

示例3: handle

 public function handle($request, \Closure $next)
 {
     // Load from cookie
     if (Cookie::has('locale')) {
         session(['locale' => Cookie::get('locale')]);
     }
     if (Session::has('locale') && Arr::exists(config('locales'), session('locale'))) {
         // Set app locale dynamically
         App::setLocale(session('locale'));
     }
     return $next($request);
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:12,代码来源:Internationalization.php

示例4: find

 /**
  * Find a handler for manage a request
  *
  * @param  string $method
  * @param  string $path
  * @return null|callable
  */
 public function find($method, $path)
 {
     $method = Str::upper($method);
     $handlers = $this->handlers[$method];
     if (Arr::exists($handlers, $path)) {
         return $handlers[$path];
     }
     foreach ($handlers as $regexPath => $handler) {
         if (preg_match('@^' . $regexPath . '$@', $path)) {
             return $handler;
         }
     }
 }
开发者ID:loduis,项目名称:alegra-php,代码行数:20,代码来源:CallableHandle.php

示例5: __callStatic

 public static function __callStatic($name, $attributes)
 {
     if (Str::startsWith('get', $name)) {
         $method = Str::camel($name);
         if (method_exists(new static(), $method)) {
             $class = static::class;
             if (Arr::exists($attributes, 0)) {
                 return $class::$method($attributes[0]);
             }
             return $class::$method();
         }
     }
     return env(Str::upper(Str::snake(Str::substr($name, 3))));
 }
开发者ID:garrinar,项目名称:laravel,代码行数:14,代码来源:Env.php

示例6: rollback

 /**
  * Rollback the last migration operation.
  *
  * @param array|string $paths
  * @param array        $options
  *
  * @return array
  */
 public function rollback($paths = [], array $options = [])
 {
     $this->notes = [];
     $rolledBack = [];
     $migrations = $this->getRanMigrations();
     $files = $this->getMigrationFiles($paths);
     $count = count($migrations);
     if ($count === 0) {
         $this->note('<info>Nothing to rollback.</info>');
     } else {
         $this->requireFiles($files);
         $steps = Arr::get($options, 'step', 0);
         if ($steps == 0) {
             $steps = 1;
         }
         $lastBatch = $this->repository->getLastBatchNumber();
         $stepDown = false;
         foreach ($migrations as $migration) {
             $migration = (object) $migration;
             if ($lastBatch > $migration->batch && $stepDown) {
                 $steps--;
                 $stepDown = false;
                 $lastBatch = $migration->batch;
             }
             if ($steps <= 0) {
                 break;
             }
             if (Arr::exists($files, $migration->migration)) {
                 $rolledBack[] = $files[$migration->migration];
                 $stepDown = true;
                 $this->runDown($files[$migration->migration], $migration, Arr::get($options, 'pretend', false));
             }
         }
     }
     return $rolledBack;
 }
开发者ID:caffeinated,项目名称:modules,代码行数:44,代码来源:Migrator.php

示例7: explode

 /**
  * Set an item on an array or object using dot notation.
  *
  * @param  mixed  $target
  * @param  string|array  $key
  * @param  mixed  $value
  * @param  bool  $overwrite
  * @return mixed
  */
 function data_set(&$target, $key, $value, $overwrite = true)
 {
     $segments = is_array($key) ? $key : explode('.', $key);
     if (($segment = array_shift($segments)) === '*') {
         if (!Arr::accessible($target)) {
             $target = [];
         }
         if ($segments) {
             foreach ($target as &$inner) {
                 data_set($inner, $segments, $value, $overwrite);
             }
         } elseif ($overwrite) {
             foreach ($target as &$inner) {
                 $inner = $value;
             }
         }
     } elseif (Arr::accessible($target)) {
         if ($segments) {
             if (!Arr::exists($target, $segment)) {
                 $target[$segment] = [];
             }
             data_set($target[$segment], $segments, $value, $overwrite);
         } elseif ($overwrite || !Arr::exists($target, $segment)) {
             $target[$segment] = $value;
         }
     } elseif (is_object($target)) {
         if ($segments) {
             if (!isset($target->{$segment})) {
                 $target->{$segment} = [];
             }
             data_set($target->{$segment}, $segments, $value, $overwrite);
         } elseif ($overwrite || !isset($target->{$segment})) {
             $target->{$segment} = $value;
         }
     } else {
         $target = [];
         if ($segments) {
             data_set($target[$segment], $segments, $value, $overwrite);
         } elseif ($overwrite) {
             $target[$segment] = $value;
         }
     }
     return $target;
 }
开发者ID:mark86092,项目名称:laravel-framework,代码行数:53,代码来源:helpers.php

示例8: exists

 /**
  * {@inheritdoc}
  */
 public function exists($key)
 {
     $keys = is_array($key) ? $key : func_get_args();
     foreach ($keys as $value) {
         if (!Arr::exists($this->attributes, $value)) {
             return false;
         }
     }
     return true;
 }
开发者ID:delatbabel,项目名称:framework,代码行数:13,代码来源:Store.php


注:本文中的Illuminate\Support\Arr::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。