Laravel 8 reverse() {#collection-method}
reverse
方法用来倒转集合项的顺序,并保留原始的键:
$collection = collect(['a', 'b', 'c', 'd', 'e']);
$reversed = $collection->reverse();
$reversed->all();
/*
[
4 => 'e',
3 => 'd',
2 => 'c',
1 => 'b',
0 => 'a',
]
*/