__construct() __construct(array $items = []) : mixed Collection constructor. Parameters array $items 数据 Returns mixed —
merge() merge(mixed $items) : static 合并数组并返回一个新的 Collection 实例 Parameters mixed $items 新的数据 Returns static —
diff() diff(mixed $items) : static 比较数组,返回差集生成的新 Collection 实例 Parameters mixed $items 做比较的数据 Returns static —
intersect() intersect(mixed $items) : static 比较数组,返回交集组成的 Collection 新实例 Parameters mixed $items 比较数据 Returns static —
unshift() unshift(mixed $value, mixed $key = null) : void 在数组开头插入一个元素 Parameters mixed $value 值 mixed $key 键名
push() push(mixed $value, mixed $key = null) : void 在数组结尾插入一个元素 Parameters mixed $value 值 mixed $key 键名
reduce() reduce(callable $callback, mixed $initial = null) : mixed 通过使用用户自定义函数,以字符串返回数组 Parameters callable $callback 回调函数 mixed $initial 初始值 Returns mixed —
chunk() chunk(int $size, bool $preserveKeys = false) : static 把数据分割为新的数组块 Parameters int $size 分隔长度 bool $preserveKeys 是否保持原数据索引 Returns static —
each() each(callable $callback) : $this 给数据中的每个元素执行回调 Parameters callable $callback 回调函数 Returns $this —
filter() filter(callable|null $callback = null) : static 用回调函数过滤数据中的元素 Parameters callable|null $callback 回调函数 Returns static —
column() column(mixed $columnKey, null $indexKey = null) : array 返回数据中指定的一列 Parameters mixed $columnKey 键名 null $indexKey 作为索引值的列 Returns array —
sort() sort(callable|null $callback = null) : static 对数据排序,并返回排序后的数据组成的新 Collection 实例 Parameters callable|null $callback 回调函数 Returns static —
slice() slice(int $offset, int $length = null, bool $preserveKeys = false) : static 截取数据并返回新的 Collection 实例 Parameters int $offset 起始位置 int $length 截取长度 bool $preserveKeys 是否保持原先的键名 Returns static —
offsetExists() offsetExists(mixed $offset) : bool 指定的键是否存在 Parameters mixed $offset 键名 Returns bool —
offsetSet() offsetSet(mixed $offset, mixed $value) : void 设置键值 Parameters mixed $offset 键名 mixed $value 值
toJson() toJson(int $options = JSON_UNESCAPED_UNICODE) : string 转换当前数据集为 JSON 字符串 Parameters int $options json 参数 Returns string —
convertToArray() convertToArray(mixed $items) : array 将数据转换成数组 Parameters mixed $items 数据 Returns array —