mobileka/mosaic-array
最新稳定版本:1.0.0
Composer 安装命令:
composer require mobileka/mosaic-array
包简介
A simple array manipulation class
README 文档
README
A simple array manipulation class.
Requirements:
PHP >= 5.4.*
Some examples:
A very common case when you need to do something like this:
if (isset($arr['key']) { $result = $arr['key']; } else { $result = 'default'; } // another way to write the same thing $result = isset($arr['key']) ? $arr['key'] : 'default';
With MosaicArray you can do the same thing more elegantly:
$result = MosaicArray::make($arr)->getItem('key', 'default'); //or $ma = new MosaicArray($arr); $result = $ma->getItem('key', 'default');
MosaicArray implements ArrayAccess, IteratorAggregate, Countable and Serializable interfaces, so you can access an instance of this class as an array, iterate over it, count elements, serialize and unserialize it:
$numbers = new MosaicArray([1, 2, 3]); echo $numbers[0]; //1 foreach ($numbers as $number) { // do something } echo count($numbers); // 3 serialize($numbers); unserialize($numbers);
License
MosaicArray is open-source and licensed under the MIT License
统计信息
- 总下载量: 1.24k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-15