菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
1828
18

基于 Laravel collect 的 PHP Extension

原创
05/13 14:22
阅读数 1920

介绍:

vcollect 是一个PHP c extension,提供流畅、便利的数组数据操作。
file

安装:

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:

发表评论

0/200
1828 点赞
18 评论
收藏
为你推荐 换一批