首页> 实战笔录 >PHP开发笔记 >Laravel Laravel

Lavarel集合collect()可用方法大全分享

作者:小萝卜 2024-08-01 浏览 1165

简介对于剩余的大部分集合文档,我们将讨论 Collection 类中可用的每个方法。请记住,所有这些方法都可以链式调用,以便流畅地操作底层数组。此外,几乎每个方法都会返回一个新的 Collection 实例,允许你在必要时保留集合的原始副本:

Lavarel集合collect()可用方法大全

 

all                                                 #返回由集合表示的底层数组

average                                       

avg

chunk                                           #将集合分成多个给定大小的较小集合(有点类似于php的array_chunk方法)

chunkWhile

 collapse

collect

combine

concat

contains

containsStrict

count

countBy

crossJoin

dd

diff

diffAssoc

diffKeys

doesntContain

dump

duplicates

duplicatesStrict

each

eachSpread

every

except

filter

first

firstOrFail

firstWhere

flatMap

flatten

flip

forget

forPage

get

groupBy

has

implode

intersect

intersectByKeys

isEmpty

isNotEmpty

join

keyBy

keys

last

lazy

macro

make

map

mapInto

mapSpread

mapToGroups

mapWithKeys

max

median

merge

mergeRecursive

min

mode

nth

only

pad

partition

pipe

pipeInto

pipeThrough

pluck

pop

prepend

pull

push

put

random

range

reduce

reduceSpread

reject

replace

replaceRecursive

reverse

search

shift

shuffle

skip

skipUntil

skipWhile

slice

sliding

sole

some

sort

sortBy

sortByDesc

sortDesc

sortKeys

sortKeysDesc

sortKeysUsing

splice

split

splitIn

sum

take

takeUntil

takeWhile

tap

times

toArray

toJson

transform                                                        #遍历整个集合,并对集合中的每个元素都会调用其回调函数

undot

union

unique

uniqueStrict

unless

unlessEmpty

unlessNotEmpty

unwrap

value

values

when

whenEmpty

whenNotEmpty

where

whereStrict

whereBetween

whereIn

whereInStrict

whereInstanceOf

whereNotBetween

whereNotIn

whereNotInStrict

whereNotNull

whereNull

wrap

zip

很赞哦! (0)

文章评论

    高端网站建设