本文整理汇总了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();
}
示例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']);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例12: getBindings
/**
* Get the current query value bindings in a flattened array.
*
* @return array
*/
public function getBindings()
{
return Arr::flatten($this->bindings);
}
示例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);
}
示例14:
/**
* Flatten a multi-dimensional array into a single level.
*
* @param array $array
* @return array
*/
function array_flatten($array)
{
return Arr::flatten($array);
}
示例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)));
}