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


PHP Arr::flatten方法代码示例

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


在下文中一共展示了Arr::flatten方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __invoke

 /**
  * @param array $data
  * @return void
  */
 public function __invoke($data)
 {
     $data = Arr::flatten($data);
     $data = array_unique($data);
     $this->outPorts['out']->send($data);
     $this->outPorts['out']->disconnect();
 }
开发者ID:aretecode,项目名称:planck-id,代码行数:11,代码来源:FlattenAndUniqueArray.php

示例2: __invoke

 public function __invoke($data)
 {
     lineOut(__METHOD__);
     lineOut('ReplaceMarkupClasses');
     // lineOut('data:'); lineOut($data); lineOut('this content:'); lineOut($this->content);
     // (?:\s|\")
     #'/(?<=class\=)(?:\"|\')(?:[a-zA-Z0-9\s]*?)\b('.$data['original'].')\b(?=\"|\'|\s)/s',
     // could match them all, explode it, make a copy, replace it...
     $content = (string) $data['content'];
     preg_match_all('/(?<=class\\=\\")([a-zA-Z0-9-\\s]*)(?=\\")/s', $content, $matches);
     $matches = Arr::flatten($matches);
     $matchCopy = "";
     // echo "CLEAN UP MATCH: ". __METHOD__;
     foreach ($matches as $match) {
         $matchesExploded = explode(" ", $match);
         foreach ($matchesExploded as $key => $subMatch) {
             $matchesExploded[$key] = str_replace($data['original'], $data['new'], $subMatch);
         }
         $matchesImploded = implode(" ", $matchesExploded);
         $content = str_replace($match, $matchesImploded, $content);
     }
     $data['content']->setContent($content);
     /*
     $data['content']->setContent(preg_replace(
         '/(?<=class\=)(?:\"|\')(?:[a-zA-Z0-9\s]*?)\b('.$data['original'].')\b(?:\"|\')(?:[a-zA-Z0-9\s]*?)(?=\"|\'|\s)/',
         $data['new'],
         $data['content']));
     */
     // $this->content = $data['content'];
     $this->sendIfAttached('out', $data['content']);
 }
开发者ID:aretecode,项目名称:planck-id,代码行数:31,代码来源:ReplaceMarkupClasses.php

示例3: buildSource

 public static function buildSource($raw, $argument)
 {
     preg_match_all('/[(]+[A-Za-z]+[)]/', $raw, $matches);
     $matches = Arr::flatten($matches);
     foreach ($matches as $match) {
         $method = preg_replace('/[()]/', '', $match);
         $name = forward_static_call(['self', $method], $argument);
         $raw = str_replace($match, $name, $raw);
     }
     return $raw;
 }
开发者ID:elepunk,项目名称:oven,代码行数:11,代码来源:Parser.php

示例4: write

 /**
  * Write the stored logs.
  *
  * @return array
  */
 public function write()
 {
     foreach ($this->logs as $file => $entries) {
         $entries = Arr::flatten($entries);
         if (!$this->files->exists($file)) {
             $this->createLogsFile($file);
         }
         $this->files->put($file, implode(PHP_EOL, $entries));
     }
     return array_keys($this->logs);
 }
开发者ID:clone1018,项目名称:rocketeer,代码行数:16,代码来源:LogsHandler.php

示例5: output

 /**
  * @param  mixed  $data
  * @return void
  */
 public function output($data)
 {
     if (is_array($data)) {
         lineOut(__METHOD__);
         $dataString = Arr::flatten($data);
         $dataString = array_unique($dataString);
         $dataString = implode(",", $dataString);
         Emitter::emit('test.output', $dataString);
         lineOut($dataString);
     }
     lineOut(__METHOD__ . ' - original;');
     lineOut($data);
 }
开发者ID:aretecode,项目名称:planck-id,代码行数:17,代码来源:DisplayOutputForTesting.php

示例6: get

 /**
  * @uses   $this->regex
  * @param  mixed $data
  * @return array matches
  */
 protected function get($data)
 {
     $dataExtended = $data;
     if (is_array($data)) {
         $dataExtended = implode(" ", $data);
     }
     $matches = pregMatchAll($dataExtended, $this->regex);
     if (is_array($matches)) {
         $matches = Arr::flatten($matches);
     }
     if (is_array($matches) && count($matches) === 0 && $this->outPorts['error']->isAttached()) {
         $this->outPorts['error']->send($matches);
     }
     Emitter::emit('regex.inout', $matches, static::class);
     return $matches;
 }
开发者ID:aretecode,项目名称:planck-id,代码行数:21,代码来源:RegexInOut.php

示例7: process

 /**
  * Process data to output on browser
  *
  * @param bool $object
  * @return array
  */
 public function process($object = false)
 {
     $this->output = [];
     foreach ($this->results as $row) {
         $data = Helper::convertToArray($row);
         $value = $this->addColumns($data, $row);
         $value = $this->editColumns($value, $row);
         $value = $this->setupRowVariables($value, $row);
         if (!$object) {
             $value = Arr::flatten($this->removeExcessColumns($value));
         } else {
             $value = $this->removeExcessColumns($value);
         }
         $this->output[] = $value;
     }
     return $this->output;
 }
开发者ID:ntamvl,项目名称:laravel-datatables,代码行数:23,代码来源:DataProcessor.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @param  string $target_field
  * @param  string $glue
  * @param  string,... $source_field
  * @return mixed
  */
 public function handle($request, Closure $next, $target_field, $glue = 'COMMA', $source_field = null)
 {
     //Commas can’t be used by \Illuminate\Pipeline\Pipeline::parsePipeString
     $glue = str_replace('COMMA', ',', $glue);
     $source_fields = array_slice(func_get_args(), 4);
     $concat_values = [];
     if (count($source_fields)) {
         foreach ($source_fields as $source_field) {
             $source_value = $request->input($source_field);
             if (is_array($source_value) or strlen($source_value)) {
                 $concat_values[] = $source_value;
             } else {
                 //This value is empty so stop here and only concatenate the collected values
                 break;
             }
         }
     } else {
         $concat_values = (array) $request->input($target_field);
     }
     $concat_values = Arr::flatten($concat_values);
     $this->setRequestInput($request, $target_field, implode($glue, $concat_values));
     return $next($request);
 }
开发者ID:fewagency,项目名称:laravel-reformulator,代码行数:33,代码来源:ConcatenateInput.php

示例9: flatten

 /**
  * Get a flattened array of the items in the collection.
  *
  * @param  int  $depth
  * @return static
  */
 public function flatten($depth = INF)
 {
     return new static(Arr::flatten($this->items, $depth));
 }
开发者ID:jeandrocouto,项目名称:warmupdelivery,代码行数:10,代码来源:Collection.php

示例10:

 /**
  * Flatten a multi-dimensional array into a single level.
  *
  * @param  array $array
  * @param  int $depth
  * @return array
  */
 function array_flatten($array, $depth = INF)
 {
     return Arr::flatten($array, $depth);
 }
开发者ID:saj696,项目名称:pipe,代码行数:11,代码来源:helpers.php

示例11: getOutputColumns

 /**
  * Get sColumns output
  *
  * @return array
  */
 private function getOutputColumns()
 {
     $columns = array_merge($this->useDataColumns(), $this->sColumns);
     $columns = array_diff($columns, $this->excess_columns);
     return Arr::flatten($columns);
 }
开发者ID:testoodoo,项目名称:OoodooSiteUp,代码行数:11,代码来源:Datatables.php

示例12: getBindings

 /**
  * Get the current query value bindings in a flattened array.
  *
  * @return array
  */
 public function getBindings()
 {
     return Arr::flatten($this->bindings);
 }
开发者ID:denise92,项目名称:cms,代码行数:9,代码来源:Builder.php

示例13: getRelations

 /**
  * Get all relations of model from callable.
  *
  * @return array
  */
 public function getRelations()
 {
     $relations = $columns = [];
     foreach ($this->builder->fields() as $field) {
         $columns[] = $field->column();
     }
     foreach (Arr::flatten($columns) as $column) {
         if (Str::contains($column, '.')) {
             list($relation) = explode('.', $column);
             if (method_exists($this->model, $relation) && $this->model->{$relation}() instanceof Relation) {
                 $relations[] = $relation;
             }
         } elseif (method_exists($this->model, $column)) {
             $relations[] = $column;
         }
     }
     return array_unique($relations);
 }
开发者ID:barryzhang,项目名称:laravel-admin,代码行数:23,代码来源:Form.php

示例14:

 /**
  * Flatten a multi-dimensional array into a single level.
  *
  * @param  array  $array
  * @return array
  */
 function array_flatten($array)
 {
     return Arr::flatten($array);
 }
开发者ID:eunicon,项目名称:meetup,代码行数:10,代码来源:helpers.php

示例15: prepareBindingsForUpdate

 /**
  * Prepare the bindings for an update statement.
  *
  * @param  array  $bindings
  * @param  array  $values
  * @return array
  */
 public function prepareBindingsForUpdate(array $bindings, array $values)
 {
     $bindingsWithoutJoin = Arr::except($bindings, 'join');
     return array_values(array_merge($values, $bindings['join'], Arr::flatten($bindingsWithoutJoin)));
 }
开发者ID:bryanashley,项目名称:framework,代码行数:12,代码来源:PostgresGrammar.php


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