基于 Laravel collect 的 PHP Extension
介绍:
vcollect
是一个PHP c extension,提供流畅、便利的数组数据操作。
安装:
1、Clone
定位于PHP下的ext目录,执行
git clone https://github.com/VikinDev/v-collect.git
2、编译安装
在扩展目录内,执行
phpize
./configure
make && make install
3、修改ini
在php.ini文件中加入extension = vcollect.so
使用
创建集合
$test = vcollect([1, 2, 3, 4, 5, 6]);
可用方法
^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ |
---|---|---|---|---|---|---|---|---|---|
map | collapse | avg | has | mx | mi | toJson | toArray | take | pluck |
where |
where
快速过滤或筛选集合
$vcollect = vcollect([
['developer' => ['name' => 'Taylor', 'option' => ['test' => 'one'] ] ],
['developer' => ['name' => 'Abigail', 'option' => ['test' => 'two'] ] ]
]);
$vcollect->where('developer.option.test', 'one')->toArray();
// ['developer' => ['name' => 'Taylor', 'option' => ['test' => 'one'] ] ]
......
github: https://github.com/VikinDev/v-collect
:relaxed:
欢迎各位star,我会继续努力!向各位大佬学习;:clap:
推荐文章: