阅读(4045) (13)

Laravel 8 pop() {#collection-method}

2021-07-01 15:42:02 更新

pop 从原集合返回并移除集合中的最后一项:

$collection = collect([1, 2, 3, 4, 5]);

$collection->pop();

// 5

$collection->all();

// [1, 2, 3, 4]