thanhtaivtt/collection
Composer 安装命令:
composer require thanhtaivtt/collection
包简介
Array collection for PHP
README 文档
README
Install
composer require thanhtaivtt/collection
Usage
use thanhtaivtt\Collection\Collection; //init $collection = new Collection([1,2,3,4,5,6]); //or Collection::init([1,2,3,6,4]);
Suport Methods
sum
- The
summethod returns the sum of all items in the collection:
Collection::init([1, 2, 3])->sum(); // 6
sum
- The
avgmethod returns the average of all items in the collection:
Collection::init([1, 2, 3])->avg(); // 2
min
- The
minmethod returns the min of all items in the collection:
Collection::init([1, 2, 3])->min(); // 1
max
- The
maxmethod returns the max of all items in the collection:
Collection::init([1, 2, 3])->max(); // 1
all
- The
allmethod returns the all items in the collection:
Collection::init([1, 2, 3])->all(); // [1,2,3]
chunk
- The
chunkmethod breaks the collection into multiple, smaller collections of a given length:
$chunk = Collection::init([1, 2, 3])->chunk(2); $chunk->toArray(); // [[1, 2], [3]]
toArray
- The
toArraymethod converts all items in Object to Array:
$chunk = Collection::init([1, 2, 3])->toArray(); // [1, 2, 3]
....
统计信息
- 总下载量: 69
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-18