阅读(4675)
赞(5)
Laravel 8 shuffle() {#collection-method}
2021-07-01 15:42:05 更新
shuffle
方法随机打乱元素:
$collection = collect([1, 2, 3, 4, 5]);
$shuffled = $collection->shuffle();
$shuffled->all();
// [3, 2, 5, 1, 4] - (generated randomly)