Properties

$items

$items : array

数据集数据

Type

array

Methods

__construct()

__construct(mixed  $items = []) : mixed

Parameters

mixed $items

Returns

mixed —

make()

make(mixed  $items = []) : mixed

Parameters

mixed $items

Returns

mixed —

isEmpty()

isEmpty() : bool

是否为空

Returns

bool —

toArray()

toArray() : mixed

Returns

mixed —

all()

all() : mixed

Returns

mixed —

merge()

merge(mixed  $items) : static

合并数组

Parameters

mixed $items

Returns

static —

flip()

flip() : static

交换数组中的键和值

Returns

static —

dictionary()

dictionary(mixed  $items = null, string  $indexKey = null) : array

按指定键整理数据

Parameters

mixed $items

数据

string $indexKey

键名

Returns

array —

diff()

diff(mixed  $items, string  $indexKey = null) : static

比较数组,返回差集

Parameters

mixed $items

数据

string $indexKey

指定比较的键名

Returns

static —

intersect()

intersect(mixed  $items, string  $indexKey = null) : static

比较数组,返回交集

Parameters

mixed $items

数据

string $indexKey

指定比较的键名

Returns

static —

keys()

keys() : array

返回数组中所有的键名

Returns

array —

pop()

pop() : mixed

删除数组的最后一个元素(出栈)

Returns

mixed —

reduce()

reduce(callable  $callback, mixed  $initial = null) : mixed

通过使用用户自定义函数,以字符串返回数组

Parameters

callable $callback
mixed $initial

Returns

mixed —

reverse()

reverse() : static

以相反的顺序返回数组。

Returns

static —

shift()

shift() : mixed

删除数组中首个元素,并返回被删除元素的值

Returns

mixed —

push()

push(mixed  $value, mixed  $key = null) : void

在数组结尾插入一个元素

Parameters

mixed $value
mixed $key

chunk()

chunk(int  $size, bool  $preserveKeys = false) : static

把一个数组分割为新的数组块.

Parameters

int $size
bool $preserveKeys

Returns

static —

unshift()

unshift(mixed  $value, mixed  $key = null) : void

在数组开头插入一个元素

Parameters

mixed $value
mixed $key

each()

each(callable  $callback) : $this

给每个元素执行个回调

Parameters

callable $callback

Returns

$this —

map()

map(callable|null  $callback) : static

用回调函数处理数组中的元素

Parameters

callable|null $callback

Returns

static —

filter()

filter(callable|null  $callback = null) : static

用回调函数过滤数组中的元素

Parameters

callable|null $callback

Returns

static —

where()

where(string  $field, mixed  $operator, mixed  $value = null) : static

根据字段条件过滤数组中的元素

Parameters

string $field

字段名

mixed $operator

操作符

mixed $value

数据

Returns

static —

column()

column(mixed  $columnKey, mixed  $indexKey = null) : array

返回数据中指定的一列

Parameters

mixed $columnKey

键名

mixed $indexKey

作为索引值的列

Returns

array —

sort()

sort(callable|null  $callback = null) : static

对数组排序

Parameters

callable|null $callback

Returns

static —

order()

order(string  $field, string  $order = null, bool  $intSort = true) : $this

指定字段排序

Parameters

string $field

排序字段

string $order

排序

bool $intSort

是否为数字排序

Returns

$this —

shuffle()

shuffle() : static

将数组打乱

Returns

static —

slice()

slice(int  $offset, int  $length = null, bool  $preserveKeys = false) : static

截取数组

Parameters

int $offset
int $length
bool $preserveKeys

Returns

static —

offsetExists()

offsetExists(mixed  $offset) : mixed

Parameters

mixed $offset

Returns

mixed —

offsetGet()

offsetGet(mixed  $offset) : mixed

Parameters

mixed $offset

Returns

mixed —

offsetSet()

offsetSet(mixed  $offset, mixed  $value) : mixed

Parameters

mixed $offset
mixed $value

Returns

mixed —

offsetUnset()

offsetUnset(mixed  $offset) : mixed

Parameters

mixed $offset

Returns

mixed —

count()

count() : mixed

Returns

mixed —

getIterator()

getIterator() : mixed

Returns

mixed —

jsonSerialize()

jsonSerialize() : mixed

Returns

mixed —

toJson()

toJson(int  $options = JSON_UNESCAPED_UNICODE) : string

转换当前数据集为JSON字符串

Parameters

int $options

json参数

Returns

string —

__toString()

__toString() : mixed

Returns

mixed —

convertToArray()

convertToArray(mixed  $items) : array

转换成数组

Parameters

mixed $items

Returns

array —