定制 yarri/array-flatten 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yarri/array-flatten

Composer 安装命令:

composer require yarri/array-flatten

包简介

Convert a multi-dimensional array into a single-dimensional array

README 文档

README

Tests

Convert a multi-dimensional array into a single-dimensional array

Function signature

array_flatten(array $array, bool $preserve_keys = false): array

Parameters

array

The multi-dimensional array.

preserve_keys

Whether or not to preserve keys in the output array.

Return value

The function array_flatten returns single-dimensional array or false if no array is given as the parameter $array.

Usage

$ar = ["a", ["b", "c"], [["d",["e","f"]]]];
array_flatten($ar); // ["a","b","c","d","e","f"]

$ar = ["x" => "a", "y" => ["z" => "b", "c"]];
array_flatten($ar); // ["a", "b", "c"]
array_flatten($ar,false); // ["a", "b", "c"]
array_flatten($ar,true); // ["x" => "a", "z" => "b", 0 => "c"]

// !! duplicit key "x"
$ar = ["x" => "a", "y" => ["z" => "b", "x" => "c"]];
array_flatten($ar); // ["a", "b", "c"]
array_flatten($ar,true); // ["x" => "c", "z" => "b"]

Installation

Just use the Composer:

composer require yarri/array-flatten

License

ArrayFlatten is free software distributed under the terms of the MIT license

统计信息

  • 总下载量: 6.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固