定制 minwork/array 二次开发

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

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

minwork/array

最新稳定版本:v1.13.5

Composer 安装命令:

composer require minwork/array

包简介

Pack of advanced array functions specifically tailored for: associative (assoc) array, multidimensional array, array of objects and handling nested array elements

README 文档

README

Build Status Coverage Status Latest Stable Version Github Stars

Pack of array convenience methods for handling:

  • Nested arrays
  • Arrays of objects
  • Associative arrays
  • Chaining array transformations

Easily create, access, validate, manipulate and transform arrays

Advanced implementation of well known operations:

Installation

composer require minwork/array

Advantages

  • Thoroughly tested
  • Well documented
  • Leverages PHP 7 syntax and speed
  • No external dependencies
  • Large variety of usages

Example of usage

// Set nested array value
$array = Arr::set([], 'key1.key2.key3', 'my_value'); 
// Which is equivalent to
[
  'key1' => [
    'key2' => [
      'key3' => 'my_value'
    ]
  ]
]

// Get nested array value
Arr::get($array, 'key1.key2') -> ['key3' => 'my_value']

// Check if array has nested element
Arr::has($array, 'key1.key2.key3') -> true 

// Map array while accessing it's key
Arr::map($array, function ($key, $value) {
   // Your code here
});

// Find array element
Arr::find($array, function ($element) {
  return Arr::get($element, 'key2.key3') === 'my_value';
}) -> [ 'key2' => [ 'key3' => 'my_value'] ]

// Chain few methods
Arr::obj(['test' => 1, 'foo' => 'bar'])
    ->set('abc', 123)
    ->set('[]', 'auto_index')
    ->remove('foo')
    ->getArray() 
->
[
  'test' => 1,
  'abc' => 123,
  'auto_index'
]

// Group objects by the result of calling method 'getSize' on each object
Arr::groupObjects([$cat, $dog, $fish, ...], 'getSize') ->
[
  'medium' => [$cat, $dog, ...],
  'small' => [$fish, ...],
  ...
]

Documentation

https://minwork.gitbook.io/array/

统计信息

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

GitHub 信息

  • Stars: 63
  • Watchers: 4
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-05